Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

custom operators !?

 [1/5] from: maximo::meteorstudios::com at: 24-Jul-2003 13:53


I know its been talked about before, but since versions have moved on pretty much since last I saw a thread on this, I'll open a (short?) discussion on it. The question is simple: can we now build our own operators? something like: make-binary-operator "+=" [a [number!] b [number!]][ return (a + b) ] make-unary-operator "++" [a [number!]][ return (a + 1) ]
> value: 5 > value ++ > value += 3
==9 -max ----------- meteor Studios, T.D. ----------- Strong enough for a man, but made for a woman

 [2/5] from: AJMartin:orcon at: 25-Jul-2003 6:18


max wrote:
> can we now build our own operators?
No, not directly in Rebol, AFAIK. But Gabriele's custom-types might allow this? Alternatively, you could use a dialect, like this simplistic example:
>> a: 123
== 123
>> parse [a += 2] [set Word word! '+= set Increment integer! (set Word
Increment + get Word) end] == true
>> a
== 125 Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://Valley.150m.com/

 [3/5] from: maximo:meteorstudios at: 24-Jul-2003 14:33


yeah ... but the point of adding operators, is to actually bind them to the global context... otherwise they aren't really operators, but parts of a dialect... which is a language all its own IMO. thanks for the example on how to make a little parser for it... I'm not that good with the parser for such things... how bout it Gabrielle, can your custom-types system work for me... no matter how complex to rig-up -max

 [4/5] from: g:santilli:tiscalinet:it at: 25-Jul-2003 9:52


Hi Andrew, On Thursday, July 24, 2003, 8:18:11 PM, you wrote: AJM> No, not directly in Rebol, AFAIK. But Gabriele's custom-types might allow AJM> this? You can have new types and new actions with it, but not new operators. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [5/5] from: g:santilli:tiscalinet:it at: 25-Jul-2003 9:51


Hi Maxim, On Thursday, July 24, 2003, 7:53:13 PM, you wrote: MOA> can we now build our own operators? You can't. MOA> something like: [...] Actually, I would imagine it working as it does on R#, i.e. you have: f: func [a b] [...] and then say: o: make op! :f Anyway, prefix notation is less ambiguous and simpler, so I'm not sure it's really worth having it. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/