Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: C scope and struct definitions

Reply
Thread Tools

Re: C scope and struct definitions

 
 
Tim Rentsch
Guest
Posts: n/a
 
      06-29-2012
http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de (Stefan Ram) writes:

> Tim Rentsch <(E-Mail Removed)> writes:
>>>And it seems that >>variable<< can be replace by >>object<< in
>>>these three cases.

>>I can't agree to that one. For one thing, regions of memory
>>aren't declared.

>
> This criticism would apply to N1570 too, which, for
> example, writes:
>
> >>An object declared as type _Bool is large enough to

> store the values 0 and 1<<.


Yes it would, and appropriately so.

>>Unfortunately, more sloppy language.

>
> I agree that there often is sloppy language in both ISO
> standards.


Yes, and when there is, the right thing to do is call them on it,
not pretend that the sloppy language makes sense or is a good way
to express things. (That's just a statement of general principle,
I don't mean to say you are one of the pretenders.)
 
Reply With Quote
 
 
 
 
Tim Rentsch
Guest
Posts: n/a
 
      06-29-2012
Keith Thompson <(E-Mail Removed)> writes:

> Kenneth Brody <(E-Mail Removed)> writes:
>> On 6/26/2012 6:18 PM, Alan Curry wrote:

> [...]
>>> A variable is a name, a value, an address, or some combination of those
>>> possibilities, depending on when you look at it.

>>
>> But, we were talking about "identifiers", of which "variables" are just a
>> small subset.

>
> I've seen several people say that a variable is a kind of identifier.
>
> I've always thought of a variable as a kind of *object*.
>
> For example, given:
>
> int xyz;
>
> I'd say that "xyz is a variable", but what I mean by that is that the
> object whose name is "xyz" is a variable. The identifier "xyz" isn't a
> "variable"; it's the *name* of a variable.


A question for clarification -- if we have a function defined as

int
nabs( int n0 ){
int n = n0;
return n > 0 ? nabs( -n ) : n;
}

and there is a call 'nabs( 1 )', then (ignoring the parameter n0)
would you say there is one variable or two? I would say there is
one variable, and two instances of that variable.
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      06-29-2012
Tim Rentsch <(E-Mail Removed)> writes:
> Keith Thompson <(E-Mail Removed)> writes:
>> Kenneth Brody <(E-Mail Removed)> writes:
>>> On 6/26/2012 6:18 PM, Alan Curry wrote:

>> [...]
>>>> A variable is a name, a value, an address, or some combination of those
>>>> possibilities, depending on when you look at it.
>>>
>>> But, we were talking about "identifiers", of which "variables" are just a
>>> small subset.

>>
>> I've seen several people say that a variable is a kind of identifier.
>>
>> I've always thought of a variable as a kind of *object*.
>>
>> For example, given:
>>
>> int xyz;
>>
>> I'd say that "xyz is a variable", but what I mean by that is that the
>> object whose name is "xyz" is a variable. The identifier "xyz" isn't a
>> "variable"; it's the *name* of a variable.

>
> A question for clarification -- if we have a function defined as
>
> int
> nabs( int n0 ){
> int n = n0;
> return n > 0 ? nabs( -n ) : n;
> }
>
> and there is a call 'nabs( 1 )', then (ignoring the parameter n0)
> would you say there is one variable or two? I would say there is
> one variable, and two instances of that variable.


I'd probably say that there are two variables (i.e., what you call an
"instance of a variable" I call a "variable").

I have no great confidence that my usage is correct and yours is
incorrect -- which is yet another reason why (at least here in clc) I
tend to avoid using the word "variable" if there's any chance of
ambiguity.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Tim Rentsch
Guest
Posts: n/a
 
      07-02-2012
Keith Thompson <(E-Mail Removed)> writes:

> Tim Rentsch <(E-Mail Removed)> writes:
>> Keith Thompson <(E-Mail Removed)> writes:
>>> Kenneth Brody <(E-Mail Removed)> writes:
>>>> On 6/26/2012 6:18 PM, Alan Curry wrote:
>>> [...]
>>>>> A variable is a name, a value, an address, or some combination of those
>>>>> possibilities, depending on when you look at it.
>>>>
>>>> But, we were talking about "identifiers", of which "variables" are just a
>>>> small subset.
>>>
>>> I've seen several people say that a variable is a kind of identifier.
>>>
>>> I've always thought of a variable as a kind of *object*.
>>>
>>> For example, given:
>>>
>>> int xyz;
>>>
>>> I'd say that "xyz is a variable", but what I mean by that is that the
>>> object whose name is "xyz" is a variable. The identifier "xyz" isn't a
>>> "variable"; it's the *name* of a variable.

>>
>> A question for clarification -- if we have a function defined as
>>
>> int
>> nabs( int n0 ){
>> int n = n0;
>> return n > 0 ? nabs( -n ) : n;
>> }
>>
>> and there is a call 'nabs( 1 )', then (ignoring the parameter n0)
>> would you say there is one variable or two? I would say there is
>> one variable, and two instances of that variable.

>
> I'd probably say that there are two variables (i.e., what you call an
> "instance of a variable" I call a "variable").
>
> I have no great confidence that my usage is correct and yours is
> incorrect -- which is yet another reason why (at least here in clc) I
> tend to avoid using the word "variable" if there's any chance of
> ambiguity.


I don't think either usage is right or wrong necessarily. At some
level I don't care what terms people use, as long as what they say
is clear and the various terms are used consistently. We might
call them "translation-time variables" and "execution-time
variables", and I think most people would understand the different
meanings intended. As one data point, the page at Wikipedia that
describes "variables" (as used with computers), uses the term in
the sense of "execution-time variable" (ie, what you call just a
variable). However, that very same page also talks about declaring
a variable, which is of course nonsensical under that sense of the
term -- one doesn't declare each execution-time variable that may
come into existence during a given program run; rather one
declares a translation-time variable that serves as a kind of
template for the many execution-time variables that arise as a
result of the single declaration.

Again, I don't care so much what terms are used, but I don't think
it's too much to ask -- especially in highly technical writing like
that used in the Standard -- that a distinction be made between a
translation-time notion and the related execution-time notion.
Certainly the two notions are strongly related; but the difference
between them is also significant, IMO profoundly so.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
member templated definitions out of class scope George C++ 1 11-08-2007 07:55 PM
scope of struct definitions James Brown C Programming 2 11-04-2006 01:02 PM
Scope in Method Definitions Curt Sampson Ruby 4 04-13-2005 08:35 AM
struct my_struct *p = (struct my_struct *)malloc(sizeof(struct my_struct)); Chris Fogelklou C Programming 36 04-20-2004 08:27 AM



Advertisments