[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: where does the syntactic sugar get defined?

Victor 'Zverok' Shepelev

5/22/2007 8:11:00 AM

From: list-bounce@example.com [mailto:list-bounce@example.com] On Behalf Of
Key Bern
Sent: Tuesday, May 22, 2007 11:03 AM
>
>core syntax vs syntactic sugar
>----------- ---------------
>4.+(12) 4 + 12
>array.[ ](13) array[13]
>persoon1.==(persoon2) persoon1 == persoon2
>if not unless
>Proc.new lambda
>
>Aren't the things from to right column preprocessed into the left
>column?

My guess is NO.

But this makes your point more clear. If you want to define new "infix
operator" (like "a mycoolnewoperator b"), it's impossible.

And the most natural for Ruby way of defining new control structures is
usage of blocks. Suppose, the language has no "unless" keyword. We CAN'T
define something to look like:

unless A
B
else
C
end

All we CAN is define something to look like:

unless A do
B
end.else do
C
end

this may be enough or not, depends of your requirements.

hope this helps.

V.