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

[REBOL] Re: Can I define an anti function?

From: rotenca:telvia:it at: 24-Feb-2004 17:05

Hi Lad,
> I have got a few notes: > > 1) I am still not convinced, that a "get argument", (alias "fetched > argument") is a good argument passing method. The disadvantage of it is, > that you cannot easily supply a result of an expression as an argument.
yes, but it is so elegant to write anti equal? instead of anti :equal? but i agree, the :arg notation is never used and it requires a reference to a value instead of the "value itself", so it is not totally "correct" to be used it in context like this. About Scheme people, if they would speak "in general", they could be right: we cannot create an anti :do and anti :make which work in every situations, but if they speak only of strict bolean functions, i think they are wrong ;-)
> 2) Otherwise your solution is very close. The only bug is probably this: > > >> f: func [get] [true] > >> anti-f: anti f > >> anti-f false > ** Script Error: Cannot use path on logic! value > ** Where: anti-f > ** Near: native func [get][true] get/any 'get
yes, i forgot to delay the get/any insertion after the bind to the function context. there are many modes to do it, and this is one of them: .. .. .. .. .. .. .. .. .. .. .. .. .. .. anti: func [[catch] f /local body x][ insert insert tail body: make block! 2 + length? first :f :not :f parse first :f [ any [ [end | refinement!] break | set x word! (insert tail body to lit-word! x) | (make error! "get and lit arguments not handled") ] ] x: next next second f: throw-on-error [make function! first :f body] while [not tail? x][x: next insert/only x 'get/any] :f ] --- Ciao Romano