473,769 Members | 6,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is "variable-name-equivalence" in c?

ben
hello,

an algorithm book i'm reading talks about the connectivity
problem/algorithm.

it gives a number of examples where the connectivity problem applies to
real life situations (like, the objects may represent computers in a
large network and the pairs represent connections between them)

another real situation example that's given is:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."

what does declaring two variable names as equivalent mean/entail in c?
are we talking about typedefs maybe? or something else?

thanks, ben
Nov 14 '05 #1
7 3013
On Wed, 26 Jan 2005 15:25:31 +0000, ben wrote:
hello,

an algorithm book i'm reading talks about the connectivity
problem/algorithm.

it gives a number of examples where the connectivity problem applies to
real life situations (like, the objects may represent computers in a
large network and the pairs represent connections between them)

another real situation example that's given is:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."

what does declaring two variable names as equivalent mean/entail in c?
AFAICS C isn't one of the programming "environmen ts" being referred to. It
does't have a direct way of saying that two variable names are
equivalent.
are we talking about typedefs maybe? or something else?


That is a possibility if you are talking about types rather than
variables. Macros are a way of creating something similar for identifiers,
which include but are not limited to variable names.

I think that something like C++'s references are a closer match to the
situation being described. Ask in comp.lang.c++ for more details.

Lawrence
Nov 14 '05 #2
ben wrote:
an algorithm book i'm reading talks about the connectivity
problem/algorithm.

it gives a number of examples where the connectivity problem applies to
real life situations (like, the objects may represent computers in a
large network and the pairs represent connections between them)

another real situation example that's given is:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."

what does declaring two variable names as equivalent mean/entail in c?
Concept not supported.
are we talking about typedefs maybe? or something else?


Fortran's EQUIVALENCE and stuff in COBOL, I should think.

--
Chris "electric hedgehog" Dollin
Nov 14 '05 #3
ben
In article <pa************ *************** *@netactive.co. uk>, Lawrence
Kirby <lk****@netacti ve.co.uk> wrote:
On Wed, 26 Jan 2005 15:25:31 +0000, ben wrote:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."

what does declaring two variable names as equivalent mean/entail in c?


AFAICS C isn't one of the programming "environmen ts" being referred to. It
does't have a direct way of saying that two variable names are
equivalent.


i see -- thanks for both of the replies.
Nov 14 '05 #4
ben wrote:
hello,

an algorithm book i'm reading talks about the connectivity
problem/algorithm.

it gives a number of examples where the connectivity problem applies to
real life situations (like, the objects may represent computers in a
large network and the pairs represent connections between them)

another real situation example that's given is:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."
Equivalent in the above contest is that the both variable has a same
value or same variable name? If a variable is in function scope then it
does not prevents you from declaring the same type and same name in the
block scope. Is that what the above quotes text means? Or it is a
compiler programming problem where you have to determine and produce an
error when a variable has been declared two times.

If the OP is more detailed then is a subject of learning.

what does declaring two variable names as equivalent mean/entail in c?
are we talking about typedefs maybe? or something else?

thanks, ben

--
"combinatio n is the heart of chess"

A.Alekhine

Mail to:
sathyashrayan AT gmail DOT com

Nov 14 '05 #5

In article <ct**********@m alatesta.hpl.hp .com>, Chris Dollin <ke**@hpl.hp.co m> writes:
ben wrote:
an algorithm book i'm reading talks about the connectivity
problem/algorithm.

another real situation example that's given is:

"Still another example arises in certain programming environments where
it is possible to declare two variable names as equivalent. The problem
is to be able to determine whether two given names are equivalent,
after a sequence of such declarations."

what does declaring two variable names as equivalent mean/entail in c?


Concept not supported.


I think you could argue that unions declare two "variable names as
equivalent", if we take "variable names" in a looser sense than how
the standard uses it. (Actually, that particular phrase doesn't seem
to appear in the the standard, but it clearly has a sense of what a
variable and its name are.)

In that more general sense, if we have:

union {int foo; int bar;} quux;

then "quux.foo" and "quux.bar" are both names for the same region of
storage, ie variable.

However:
are we talking about typedefs maybe? or something else?


Fortran's EQUIVALENCE and stuff in COBOL, I should think.


The "stuff in COBOL" would presumably be the REDEFINES clause of the
data division, which can be applied to an item to indicate that it
occupies the same location as another item:

01 item-1 pic x.
01 item-2 pic x redefines item-1.

Unlike C, which groups such "equivalent names" in a union, COBOL lets
you put a REDEFINES pretty much anywhere in the data division; thus
you can have one item redefining another that appeared pages away,
then a third redefinition somewhere else, and so forth; and in such a
case, the third might actually specify the second as the item it
redefines, so you have a chain of redefinition. That doesn't happen
in C, because the union syntax in effect does implicitly what
REDEFINES does explicitly, so the programmer can't create strange
networks of redefinitions.

That might be what the book was referring to.

--
Michael Wojcik mi************@ microfocus.com

The surface of the word "profession " is hard and rough, the inside mixed with
poison. It's this that prevents me crossing over. And what is there on the
other side? Only what people longingly refer to as "the other side".
-- Tawada Yoko (trans. Margaret Mitsutani)
Nov 14 '05 #6
Michael Wojcik wrote:

In article <ct**********@m alatesta.hpl.hp .com>, Chris Dollin
<ke**@hpl.hp.co m> writes:
ben wrote:
> an algorithm book i'm reading talks about the connectivity
> problem/algorithm.
>
> another real situation example that's given is:
>
> "Still another example arises in certain programming environments where
> it is possible to declare two variable names as equivalent. The problem
> is to be able to determine whether two given names are equivalent,
> after a sequence of such declarations."
>
> what does declaring two variable names as equivalent mean/entail in c?


Concept not supported.


I think you could argue that unions declare two "variable names as
equivalent", if we take "variable names" in a looser sense than how
the standard uses it. (Actually, that particular phrase doesn't seem
to appear in the the standard, but it clearly has a sense of what a
variable and its name are.)

In that more general sense, if we have:

union {int foo; int bar;} quux;

then "quux.foo" and "quux.bar" are both names for the same region of
storage, ie variable.


I wondered about mentioning unions. But I don't think they qualify,
because while the store overlaps, it is explicitly undefined what
happens if you write to one element and read from another [unless
at least one of them is unsigned char [], ish, yes?).

--
Chris "electric hedgehog" Dollin
Nov 14 '05 #7

In article <ct**********@m alatesta.hpl.hp .com>, Chris Dollin <ke**@hpl.hp.co m> writes:
Michael Wojcik wrote:

I think you could argue that unions declare two "variable names as
equivalent", if we take "variable names" in a looser sense than how
the standard uses it.


I wondered about mentioning unions. But I don't think they qualify,
because while the store overlaps, it is explicitly undefined what
happens if you write to one element and read from another [unless
at least one of them is unsigned char [], ish, yes?).


That sounds like a reasonable objection, sure. At any rate, the OP's
question doesn't seem to have a satisfactory C answer.

See, that's why it's good to learn a little COBOL: you get exposed
to all sorts of historical weirdness.

--
Michael Wojcik mi************@ microfocus.com

This record comes with a coupon that wins you a trip around the world.
-- Pizzicato Five
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2363
by: G Fernandes | last post by:
Hi, can someone tell me what the following words mean as per C/clc: 1) token 2) token sequence 3) scalar variable 4) vector
2
1728
by: THY | last post by:
Hi, I am having some problem, I declare few variable in a public module and use them in the web application. But after that I found that the variable declared in public variable = application("variable"), and it will be shared by all user ... but I am not very sure about it, anyone know it ? Thanks, Tee
4
2663
by: Friday | last post by:
Being an Old L.A.M.P guy, I beg you to please excuse my ignorance of dot.net (and all things Windows, for that matter). As part of an experiment (to learn enough ASP/VB.net to port a series of existing PHP scripts of mine to work on IIS), I have created the following simple function to compare a Website visitor's IP address against a varabe-array. The experiment invovleas a common scenario -- banning a Website visitor by IP Address: ...
4
11359
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb function ? Thank You. Octavio and.c:15: attention : type mismatch with previous implicit declaration and.c:11: attention : previous implicit declaration of `fb'
6
1687
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"? ----------------------------------------------------------------------- Microsoft introduced a shortcut that can be used to reference elements which include an ID attribute where the ID becomes a global variable. Some browsers reproduce this behaviours but some, most...
11
2238
by: gg9h0st | last post by:
i saw a code refactorying onload event listener window.onloadListeners=new Array(); window.addOnLoadListener=function(listener) { window.onloadListeners=listener; } why declare the onloadListeners, addOnLoadListener below window?
3
2018
by: Yansky | last post by:
If I have the following code: var abc; if(!abc){ alert('test'); }
0
9587
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.