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

x: :y question

 [1/18] from: rebolek::seznam::cz at: 3-Feb-2003 14:30


Hi, is this bug or I do not understand something?
>> a: :+ >> 1 a 2
** Script Error: a expected value2 argument of type: number pair char money date time tuple ** Near: a 2 Thanks, bolek

 [2/18] from: joel:neely:fedex at: 3-Feb-2003 8:17


Hi, Bolek, ... or a funny little wrinkle in REBOL syntax. Boleslav Brezovsky wrote:
> Hi, > is this bug or I do not understand something?
<<quoted lines omitted: 3>>
> money date time tuple > ** Near: a 2
Apparently REBOL figures out "early" (? perhaps at lexical scan ?) that (1 + 2) is equivalent to (1 + 2) for predefined words such as '+ and therefore does not make that same inference for other words simply set to the same internal (op!) value.
>> (+ 1 2)
== 3
>> a: :+ >> type? :a
== op!
>> (a 1 2)
== 3
>> (1 + 2)
== 3
>> (1 a 3)
** Script Error: a expected value2 argument of type: number pair char money date time tuple ** Near: a 3 However, ALIAS seems to allow a way to "tunnel" around that issue:
>> alias '+ "und"
== und
>> 1 und 2
== 3 As to whether this is a "bug" or not, I don't know whether RT had intended this inconsistency. -jn-

 [3/18] from: lmecir:mbox:vol:cz at: 3-Feb-2003 15:50


Hi Bolek, that is a "feature", see my comment in http://www.rebolforces.com/~ladislav/rep.html -L

 [4/18] from: rebolek:seznam:cz at: 4-Feb-2003 9:38


Thanks Joel and Ladislav. I had an idea: I need to sroll some face up or down, left or right depending on some value. I can use something like: either x < 0 [a: a + 1][a: a - 1] so I thought I can make it more REBOLish ;), something like: op: either x < 0 [:+][:-] a: a op 1 This does not work, OK. But I cannot use even 'alias, becease aliased word cannot be changed :( and that's sad :(( alias: either x < 0 ['+]['-] "op" a: a op 1 This works only once, then I've got this error: ** Script Error: Alias word is already in use: op ** Near: alias either x < 1 ok, I'll use my old code. But Joel, what does mean your:
>> (+ 1 2)
== 3 ? I can't reproduce it, for me, it's always
>> (+ 1 2) >>
(nothing happens, because type? (+ 1 2) is op!) bolek

 [5/18] from: lmecir:mbox:vol:cz at: 4-Feb-2003 11:39


Ahoj Bolku, <<Bolek>> I had an idea: I need to sroll some face up or down, left or right depending on some value. I can use something like: either x < 0 [a: a + 1][a: a - 1] so I thought I can make it more REBOLish ;), something like: op: either x < 0 [:+][:-] a: a op 1 This does not work, OK. <</Bolek>> Prefix versions work OK, see this: a: do either x < 0 [:add] [:subtract] a 1 <<Bolek>> But Joel, what does mean your:
>> (+ 1 2)
== 3 ? I can't reproduce it, for me, it's always
>> (+ 1 2) >>
(nothing happens, because type? (+ 1 2) is op!) <</Bolek>> This is probably a bug in the latest beta, before the operators worked as prefix. HTH -L

 [6/18] from: g:santilli:tiscalinet:it at: 4-Feb-2003 12:47


Hi Boleslav, On Tuesday, February 4, 2003, 9:38:14 AM, you wrote: BB> op: either x < 0 [:+][:-] BB> a: a op 1 op: either x < 0 [:add] [:subtract] a: op a 1 But then, I'd write it as: a: a + sign? - x (Well, there's a little difference, this does nothing if x is zero, while yours subtracts 1.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [7/18] from: fsievert:uos at: 4-Feb-2003 13:40


Freebell works like you would expect. Try with freebell: freebell.sourceforge.net x: -1 op: either x < 0 [:+][:-] a: 8 op 1 == 9 CU Frank On Tue, 4 Feb 2003, Boleslav Brezovsky wrote:

 [8/18] from: joel:neely:fedex at: 4-Feb-2003 6:22


Hi, Bolek, There's another way to be more "REBOLISH", IMHO... Boleslav Brezovsky wrote:
> I can use something like: > > either x < 0 [a: a + 1][a: a - 1] > > so I thought I can make it more REBOLish ;), something like: > > op: either x < 0 [:+][:-] > a: a op 1 >
a: a + either x < 0 [+1][-1] or a: a + pick [+1 -1] x < 0 refactors the selection as far into the expression as possible.
> But I cannot use even 'alias, becease aliased word cannot be changed :( > and that's sad :((
<<quoted lines omitted: 3>>
> ** Script Error: Alias word is already in use: op > ** Near: alias either x < 1
Yes, this is *VERY* disappointing. Why there should be s difference between ALIAS and SET is not clearly documented (at least to me), and making ALIAS set in concrete is very user hostile. -jn-

 [9/18] from: rotenca:telvia:it at: 4-Feb-2003 14:05


Hi Bolek,
>op: either x < 0 [:+][:-] >a: a op 1
You can use the only unused op ! !=: either x < 0 [:+][:-] a: a != 1 or re-use another op. --- Ciao Romano

 [10/18] from: rebolek:seznam:cz at: 4-Feb-2003 14:41


hi Ladislav and Gabriele, thanks for a: do either x < 0 [:add] [:subtract] a 1 I've forgotten that completely :) I was experimenting with sign? but I don't always need to add/subtract 1, sometimes it's bigger number so sign? is not usable in my case thanks and bye, bolek

 [11/18] from: joel:neely:fedex at: 4-Feb-2003 8:32


Hi, Romano, This way lies madness! ;-) Romano Paolo Tenca wrote:
> You can use the only unused op ! > > !=: either x < 0 [:+][:-] > a: a != 1 > > or re-use another op. >
... thus making the code even harder to read/understand for anyone who must work with it (including the original author, once it is no longer fresh on the mind). Extending a language with new concepts/words is one thing, but changing the meanings of concepts/words already existing in the language is quite another (cf. "glory" in _Alice_in_Wonderland_). These statements especially apply here, as the distance between the redefinition and the use of the redefined word may be arbitrarily large (in either time or lexically within the source code), thus making detection of the cause of later unpleasant surprises increasingly difficult. Just my $0.02 ... -jn-

 [12/18] from: g:santilli:tiscalinet:it at: 4-Feb-2003 17:52


Hi Boleslav, On Tuesday, February 4, 2003, 2:41:15 PM, you wrote: BB> I was experimenting with sign? but I don't always need to add/subtract BB> 1, sometimes it's bigger number so sign? is not usable in my case You can use: val: 3 a: add a val * sign? - x or something like that... Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [13/18] from: lmecir:mbox:vol:cz at: 4-Feb-2003 17:59


Hi Frank, <<Frank>> Freebell works like you would expect. Try with freebell: freebell.sourceforge.net x: -1 op: either x < 0 [:+][:-] a: 8 op 1 == 9 CU <</Frank>> Nice work, Frank

 [14/18] from: rotenca:telvia:it at: 4-Feb-2003 18:55


Hi Joel,
> ... thus making the code even harder to read/understand for anyone > who must work with it (including the original author, once it is > no longer fresh on the mind).
One must know what are his own chances and then decide what to do. Then, in the head of code, one could add: ;**************************** ;ATTENTION ;the word != is used as a redefined op! ;ATTENTION ;**************************** By another point of view, that op! has no meaning in Rebol, so if i see it, i cannot be confused by its standard meaning. The big problem for me is: why we have this only op! unused? What will happen in the future versions of Rebol to !=? To be safe I'll use it only as a local word. To say all the truth, i do not like infix operator in Rebol, but i must use them because they are MORE fast then the prefix versions. --- Ciao Romano

 [15/18] from: rotenca::telvia::it at: 4-Feb-2003 19:12

Sign?


Hi, Gabriele, Sign? should be a native, in the actual implementation is a waste of time. It is better to use inline code, specially if the 0 case can be reduced to the negative or positive case. --- Ciao Romano

 [16/18] from: petr:krenzelok:trz:cz at: 5-Feb-2003 9:15

Re: x: :y question


Ladislav Mecir wrote:
>Hi Frank, ><<Frank>>
<<quoted lines omitted: 7>>
><</Frank>> >Nice work, Frank
so, if you guys find it misconception or bug, why not send it to feedback? :-) -pekr-

 [17/18] from: rebolek:seznam:cz at: 5-Feb-2003 10:25


>> >so, if you guys find it misconception or bug, why not send it to >feedback? :-) > >-pekr-
Because there's no feedback from Feedback? ;o) bolek

 [18/18] from: petr:krenzelok:trz:cz at: 5-Feb-2003 10:57


Boleslav Brezovsky wrote:
>>so, if you guys find it misconception or bug, why not send it to >>feedback? :-)
<<quoted lines omitted: 3>>
>> >Because there's no feedback from Feedback? ;o)
hmm, in November dev. update RT promissed to do something about its feedback. IIRC Carl told us he installed separate computer to watch ml and feedback channels more properly. I sent several feedbacks and always got reply in 1 - 2 days. Maybe you could retry? RT's next step (after OSx release) should be - bugfixes IIRC. I think that we miss another dev. update, simply we want to know what direction will rebol take in 2K3, right? Cheers, -pekr-

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted