World: r3wp
[!REBOL3]
older newer | first last |
Claude 9-May-2010 [2939] | brianH in /etc/default/local i have LANG="fr_BE.UTF-8" (ubuntu lucid 10.4) |
Paul 9-May-2010 [2940] | Brian I don't know Icon so I can't say if it is the same behavior. However, what I was saying is that it would be nice to see if the expression is true then the value of the expression be assign to the set-word. A change like this would have to happen at the parsing level of the code. You couldn't just modify the operator. |
Terry 9-May-2010 [2941] | Is there a word! limitation in R3? |
Henrik 9-May-2010 [2942] | yes, but it's much higher than R2. |
Terry 9-May-2010 [2943x2] | so a map! using.. n/xyz: "value is limited? |
in other words, am i forced to use binary or strings as keys to avoid the limitation? | |
Henrik 9-May-2010 [2945] | that is unknown to me. BrianH must know. |
Terry 9-May-2010 [2946x2] | why couldn't the number of available words in R3 have been limited to memory? |
regardless, strings as keys are probably the way to go. | |
Ladislav 9-May-2010 [2948x3] | You couldn't just modify the operator. - actually, that is not true in R3 |
I can have such an "operator" even in R2, it just needs to be prefix | |
Or, if you insist, that it is impossible to have such an operator, you should at least try to specify it "thoroughly enough" for me to be able to know what are your requirements. (that is what BrianH was curious about too) | |
BrianH 9-May-2010 [2951] | Yup. And the value of the expression *is* being assigned to the set-word: the value of the expression a < 10 is either true or false. Unless you mean a different expression, at which point you should be more specific. If we understand exactly what you want, perhaps we can rig something up using magic evaluation tricks. |
PeterWood 9-May-2010 [2952] | I think Paul is asking for a short form of : b: either a < 10 [a] [false] If none is an acceptable value when the condition fails, it can be shortened to: b: if a < 10 [a] |
Paul 9-May-2010 [2953] | Yes Peterwood that is similiar to what I had in mind. I don't see this happening as I believe it would be a MAJOR change. |
PeterWood 9-May-2010 [2954] | Perhaps what I suggested will help even if it can't be shortened: >> a: 10 == 10 >> b: either a < 10 [a] [false] == false >> a: 2 == 2 >> b: either a < 10 [a] [false] == 2 |
Paul 9-May-2010 [2955] | b: either a < 10 [a][b] |
Izkata 10-May-2010 [2956] | Looks like b: min a b |
PeterWood 10-May-2010 [2957] | No because that could give the wrong answer, if b is greater than a and a is ten or greater. |
Ladislav 10-May-2010 [2958x3] | ; this works in R2 as well as in R3, since it is a prefix operator combined-lesser?: func [ :set-word [set-word!] value1 value2 ] [ if value1 < value2 [set set-word value1] ] ; usage a: 10 b: 'no combined-lesser? b: a 10 b ; == no a: 2 combined-lesser? b: a 10 b ; == 2 |
As you can see, in REBOL, MAJOR changes are in the power of the user. | |
(if you don't like the name of the operator, feel free to invent a better one, since that is a greater problem for me than to implement it) | |
Steeve 10-May-2010 [2961] | if= |
Ladislav 10-May-2010 [2962] | nice idea, maybe if< ? |
Steeve 10-May-2010 [2963] | What about a polymorphic function ? if=: func [:sw :gw :op val][op: get op gw: get gw if (gw op val) [set sw gw]] >>a: 1 >>b: 5 >>if= a: b < 10 == 5 >>if= a: b < 5 ==none |
Ladislav 10-May-2010 [2964x2] | aha, that is just for R3, as it looks |
(and behaves in a little bit different way) | |
Steeve 10-May-2010 [2966] | the same goes for R2, a little different though... |
Ladislav 10-May-2010 [2967] | yes, it can be backported |
Steeve 10-May-2010 [2968] | but honestly i don't see the gain with that mezz. if b < 5 [a: b] ...is short enough and syntaxly less obfuscated. |
Paul 10-May-2010 [2969x3] | Ladislav and Steeve, that wouldn't be the same. Your ownly showing the same functionality. What I'm talking about would require changing the tokenization and parsing to give the EXACT feature I requested. |
Steeve also your last expression should this if your trying to capture the same mezz if a < 5 [b: a] | |
But since I see no way that the exact expression capability that I desire will be implemented then I am like Steeve and say just leave it as is. | |
Ladislav 10-May-2010 [2972] | Paul, aha, you do not like the prefix form, and insist on the infix form you wrote. Then I have a surprise for you: it isn't REBOL Do dialect, since the Do dialect does not allow the infix op to take more than two arguments. Nevertheless, you are totally missing the point stating, that it would require changing the tokenization - that is patently wrong. |
Paul 11-May-2010 [2973] | Sure it would be - just do a TRACE and you will see that it has to be changed. Do evaluates - it has to be supplied the correct structure in order to evaluate correctly. |
Ladislav 11-May-2010 [2974] | It cannot help you state that. I can prove you false if I decide to do so. |
Paul 11-May-2010 [2975] | Prove me false ladislav. |
Andreas 11-May-2010 [2976x3] | I'm not Ladislav, but ... |
Paul, you want `b: a < 10` to roughly behave like `b: either a < 10 [a] [b]`, if I am not mistaken. | |
If so, such a change would neither affect tokenization nor parsing in any way: That's immediately obvious when you consider that `b: a < 10` is just syntactic sugar for `set 'b lesser? a 10`. You surely will have no troubles to write appropriate `my-set` and `my-lesser?` according to your desired behaviour. With that done, the only change necessary to implement this as default behaviour in REBOL is to use your set and lesser? (etc.) implementations instead of the current ones. Tokenization and parsing needs not be touched. | |
Paul 11-May-2010 [2979x6] | See that is NOT what I requested. I didn't request to use another set. I requested to use the current ones. |
It isn't just limited to < | |
It could also be: b: a - 3 > 11 | |
Or get much more complex expression that involves logical evaluations. | |
Introducing other functions is not what is being requested. | |
Again it would REQUIRE new Parsing to accomplish the task. | |
Andreas 11-May-2010 [2985x3] | Again, `b: a - 3 > 11` is syntactic sugar for `set 'b greater? subtract a 3 11`. |
No parsing changes needed for that either. | |
(Just changes in the implementation of set, lesser?, greater?, equal?, etc.) | |
BrianH 12-May-2010 [2988] | No change in syntax or parsing would be required. However, the DO's evaluation rules for the set-word expression *would* need to be changed. Note that these evaluation rules are *not* performed by a parser, so changing parsing would not be required, Paul. However, this change to the evaluation rules of the DO dialect would be so fundamental that we would essentially be changing the semantics of the language to that of another language. And that other language would resemble Icon more than it would REBOL, semantically. And changing the behavior of the SET, LESSER?, ... functions would not be enough because DO doesn't actually call those functions directly - it calls internal code, which may or may not also be called by those functions. But this is not a problem, because at least you wouldn't have to change the parsing. This means that all you would have to do is write your own evaluator and pass the code to that instead of DO. And create new versions of all the functions that call DO internally, behaving the same but calling your DO replacement instead. And create a context to reference those functions, and bind to that context instead of the standard system context. Basically, all you have to do is create a new dialect on the scale of the DO dialect, using the same REBOL parser, but different semantic rules. |
older newer | first last |