FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Operator precedence
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Operator precedence [message #185063 is a reply to message #185043] Tue, 25 February 2014 18:41 Go to previous messageGo to previous message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma:
Senior Member
Thomas 'PointedEars' Lahn wrote:

> Christoph Michael Becker wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Christoph Michael Becker wrote:
>>>> Thomas 'PointedEars' Lahn wrote:
>>>> > Ben Bacarisse wrote:
>>>> >> not in any normal sense of the word.
>>>> >
>>>> > Please define what you consider to be an operator in a “normal sense of
>>>> > the word”.
>>>>
>>>> It might be defined as an operator that can be used in arbitrary
>>>> expressions.
>>>
>>> A speculation,
>>
>> ACK. :)
>>
>>> one that is almost self-evidently false. Just consider
>>> the
>>> operators (including, but not just in, programming languages) that
>>> require their operands to be of a certain type.
>>
>> I have to admit that this "definition" was far to inaccurate. However,
>> regarding the syntax alone it has some appeal.
>
> This “definition” is simply nonsense. An operator is not only an operator
> when it “can be used in arbitrary expressions”. In mathematics, from which
> is the definition that fits best here, an operator is a mapping from
> elements of one or more sets to elements of another or to the same set.

That sounds "very similar" to the definition of a function. ;)

> So
> *by definition* its context and its operands (members of said sets) matter.
>
>>>> >> ECMAScript really does have one (like C and C++ do).
>>>> >
>>>> > Why do you think C and C++ have a comma operator (like ECMAScript)?
>>>>
>>>> According to the C grammar[2]:
>>>>
>>>> exp : assignment_exp
>>>> | exp ',' assignment_exp
>>>>
>>>> [1] <http://lxr.php.net/xref/PHP_5_5/Zend/zend_language_parser.y>
>>>> [2] <http://www.cs.man.ac.uk/~pjj/bnf/c_syntax.bnf>
>>>
>>> ACK; I stand corrected. For reasons I cannot explain (probably it is
> ^^^^^^^^^^^^^^^^^
>>> just late), I had assumed that the comma operator in ECMAScript also
>>> worked with assignments, and this is what I tested with C and C++:
>>>
>>> $ cat foo.c
>>> #include <stdio.h>
>>>
>>> int main() {
>>> int x = 42, 23;
>>
>> According to the C grammar[1], this use of the comma is not part of an
>> "exp", but rather an "init_declarator_list".
>>
>>> […] printf("%i\n", x);
>>> return 0;
>>> }
>>>
>>> $ gcc -Wall -o foo.out foo.c
>>> foo.c: In function ‘main’:
>>> foo.c:4:15: error: expected identifier or ‘(’ before numeric constant
>>> int x = 42, 23;
>>> ^
>>>
>>> However, in ECMAScript:
>>>
>>> | >>> var x = 42, 23;
>>
>> This use of the comma is not part of ECMAScript's "Expression", but
>> rather of "VariableDeclarationList".
>
> Please stop telling me things I know:

I have posted a message to Usenet. If you already knew these details,
fine. However, other readers might not.

Furthermore I was trying to stress my (resp. Ben's) point, that a comma
is not always an operator, even if a language defines a comma operator.

>>> | SyntaxError: Unexpected number
>>>
>>> What I meant instead was
>>>
>>> | >>> 42, 23
>>> | 23

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Correlating curl resources to some other object.
Next Topic: Experienced Web designer required
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 03:31:21 GMT 2024

Total time taken to generate the page: 0.05232 seconds