Sorry this is so delayed, but I have to exploit the chance to be anal 
:-)...

In two of the responses the language of "creating a value" was used, 
which is also dangerous in a *philosophical* way (I use the term 
extremely lightly), in such that an "expression" could also *create* NO 
value (aka undef, or NULL) in which case it is an expression that is 
creating (for lack of a better english word) a response (though I am 
sure this isn't precise enough either), even though that response has no 
value, is undefined or NULL.

Though I will give kudos for the one example given earlier:  "Also, a 
regular expression is an expression that fits a range of definitions, 
but still in it's own polymorphic way is a 'value' and can be tested 
against other values to see if it is the 'same as' or not."

And possibly this is why we call it a new language, or its *own* 
language, rather than pseudo-enlish-code or something, right drieux?? ;-)

http://danconia.org




Cody Art Supply LLC wrote:
> Hi,
> 
> I'm pretty new to perl, but I think this may help:
> 
> I believe a good 'rule of thumb' test can be "can that 'whole area that I think may 
>be an expression' be used as having some type of value?"
> 
> The reason '$x = $y + 2' is an expression is because you can legally (although 
>almost never done on purpose) use that as a value, say in 'if ($x = $y + 2) {}'.  The 
>resulting value that is returned by that expression is the value of $x.  (Most of the 
>time when you see that in an 'if' statement, the coder meant to use the '==' 
>comparison instead of the '=' assignment.)
> 
> In your question you asked 'for (my $x = 0; $x <= 100; $x++){}' being an expression.
> 
> It contains three expressions, 'my $x = 0', '$x <= 100', and '$x++' but the whole 
>block isn't one itself.  Only the middle one is used as an expression by the 
>interpreter, because it's value is observed at the beginning of every iteration in 
>the loop to see if it is equal to 'true'.  The first expression is only used to 
>initialize the start of the loop, and the last expression is used to create a change, 
>to ensure the loop's condition will vary and eventually test false and exit.
> Because of that, although they pass the 'expressions' test, you'd probably call them 
>'assignment operations' because that is their primary use, which better describes 
>their use within that context.  Still, in that case they are both assignments and 
>expressions.
> 
> As for 'for (0..100){}', it is a shortcut loop that hides the expressions by 
>declaring them implicitly... I think.  It's not an expression itself.
> 
> Also, a regular expression is an expression that fits a range of definitions, but 
>still in it's own polymorphic way is a 'value' and can be tested against other values 
>to see if it is the 'same as' or not.  Unlike most expressions, regular expressions 
>can't be reduced to an actual 'literal' value, in the way (5+4) is reduced to a 
>literal 9.
> 
> Often, if you are confused if something is an expression or not, you may be looking 
>at a block of code that contains expressions inside of it, but is not one itself.  
> 
> Hope this helps!
> 
> -----Original Message-----
> From: Connie Chan [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 7:15 AM
> To: Jenda Krynicky; begin begin
> Subject: Re: Syntax Culture
> 
> 
> 
> 
>>These are all expressions:
>>1
>>1 + 2
>>$x * 2
>>foo(1,2,3) + 49
>>(1,2) x 2
>>$x == $y
>>$x < 5
>>$x > 1 && $x < 5
>>but even this is an expression:
>>$x = $y + 2
>>
>>Basicaly "expression" is something that creates a value that you can 
>>assign to a variable, pass to a function or use as a condition.
>>
>>This means that
>>$x = $y + 2
>>IS an expression, but 
>>$x = $y + 2;
>>IS NOT! It's a statement.
>>
> 
> 
> With this, I'll have a question again =)
> how about : for (my $x = 0; $x <= 100; $x++){} ?
> In every loop, $x return the value to the middle, 
> and the middle design to roll another loop or not.
> It is doing something similar to if then else, but
> it also returning vals and condition signals... 
> So.... what is this ? And when I write as 
> for (0..100){} there is quite no difference, still 
> an invisible $x, as $_... so...sorry, dunno how to ask.. =)
> 
> Rgds,
> Connie
> 
> 
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to