World: r3wp
[Core] Discuss core issues
older newer | first last |
PeterWood 27-Apr-2009 [13642] | In other cases where you want ot break out of the inner loop, just return an empty block: >> z: func [] [return []] >> forever [do z] (escape) |
Steeve 28-Apr-2009 [13643] | Graham, catch and throw |
Graham 28-Apr-2009 [13644] | hehe .. that's what I said |
Steeve 28-Apr-2009 [13645] | ah... yes |
Geomol 1-May-2009 [13646] | Continuing from Puzzle Answers. Isn't this a bit funny or strange? First some failed attempts to make 2 a word of value 1: >> 2: 1 ** Syntax Error: Invalid time -- 2: >> set '2 1 ** Syntax Error: Invalid word-lit -- '2 >> set [2] 1 ** Script Error: Invalid argument: 2 So 2 shouldn't be a word. But then it's possible anyway with this trick: >> set to-word "2" 1 == 1 2 is still a number: >> 2 == 2 But 2 as a word exists: >> get to-word "2" == 1 I think, it's a bit strange. If it's intentional or not, I don't know. |
ICarii 1-May-2009 [13647x2] | the first behaviour (the error) would be the expected behaviour if you assume that base symbols such as number are protected from modification - this protection in R2 at least is not complete. |
consider trying to audit code with blocks made in word form.. another source of insecurity / bugs | |
Dockimbel 1-May-2009 [13649] | The only thing that blocks numbers to become word! values is the lexical scanner. When you type anything in console (or DO a file script), your input is first a string! value that gets LOADed (that's where the lexical scanner raises errors). TO-WORD allows to bypass the LOAD phase and force the conversion of any symbol to word! value. |
Geomol 1-May-2009 [13650] | Maybe it would be a good idea, if constructors like TO-WORD etc. would do a lexical scanning of the result? |
Dockimbel 1-May-2009 [13651] | Anyway, this gives us a probably unique method for strong code obfuscation. :-) |
ICarii 1-May-2009 [13652] | heh indeed! |
Geomol 1-May-2009 [13653] | heh, yeah! It's fun at times, but is it really a good idea? |
ICarii 1-May-2009 [13654] | the set to-word "2 + 2" with spaces is a bit of a worry |
Dockimbel 1-May-2009 [13655x2] | I agree, TO-WORD should enforce word! syntax rules on argument and raise syntax errors accordingly. That would be a more logical behavior. Maybe Carl had some design issues to workaround by allowing this (or maybe it's just an implementation flaw). |
>> set to-word " " "secret" == "secret" >> blk: reduce [to-word " "] == [ ] >> reduce blk == ["secret"] | |
Geomol 1-May-2009 [13657] | Good one! Nothing can be something in REBOL. :-) |
Dockimbel 1-May-2009 [13658] | There is no spoon or "The truth is elsewhere" could make nice REBOL baselines. ;-) |
ICarii 1-May-2009 [13659x2] | R3 however does do a whitespace check thankfully |
whitespace characters appear invalid in words in R3 - although if they are able to be redefined that could be an issue/weakness | |
Sunanda 1-May-2009 [13661] | Geomol <funny or strange> It gets odder ( or less consistent) as '+ does seem to be given special handing...... What I really wanted to do to solve the puzzle was: -- set to-word "2" 5 -- set to-word "+" none The block then becomes (in effect) do [5 none 5] == 5 But DOing the gimmicked block in R2 fell found of '+ being both a native and some hardwired syntax in the interpreter: set to-word "2" 5 set to-word "+" none blk: copy [] blk: reduce [to-word "2" to-word "+" to-word "2"] probe blk == [2 + 2] do blk ** Script Error: Invalid operator: + ** Near: 2 + 2 |
BrianH 1-May-2009 [13662] | In R2 the operators are special-cased by DO. In R3 they handle themselves (quicker that way). |
[unknown: 5] 8-May-2009 [13663x3] | Wouldn't it be nice to do: series: [1 2 3 4 5 6 7 8 9 10] find series > 5 |
such that it returns: [6 7 8 9 10] | |
Even extend that to use CHAR values also. | |
Maxim 8-May-2009 [13666x2] | I agree that adding a refinement to include a compare func would be pretty usefull! |
maybe some other func provides this and we're not thinking about it. | |
[unknown: 5] 8-May-2009 [13668x2] | Seem I'm always wanting this functionality and would be a very useful upgrade. |
Could be Maxim, I often put something down - only to find Gabriele or Ladislav showing me another way. | |
Janko 8-May-2009 [13670] | there is something like filter function I think (or you can make one that takes values and expression) |
[unknown: 5] 8-May-2009 [13671] | I know we can easily build a function to do this but it seems so well suited to the 'find function. |
Maxim 8-May-2009 [13672] | find/match series (6 = pick serie 1) would make a lot of sense to me. |
kcollins 8-May-2009 [13673] | In R3: remove-each x series [x <= 5] |
[unknown: 5] 8-May-2009 [13674x2] | We ave remove-each in R2 also but that is a bit different as it is doing removal - I don't want something removed just a subset returned. |
I submitted my request to cure-code. | |
Maxim 8-May-2009 [13676] | yess remove actuall modifies the series being given, find just changes its offest. |
Henrik 8-May-2009 [13677] | it would be more like extract with a /find index. |
kcollins 8-May-2009 [13678] | You could copy the series first, although obviously this impacts performance. |
[unknown: 5] 8-May-2009 [13679] | http://curecode.org/rebol3/ticket.rsp?id=781 |
Henrik 8-May-2009 [13680] | have we had a discussion about a variable /skip based on FIND? I think it's a good idea in general. |
[unknown: 5] 8-May-2009 [13681] | not sure. |
Janko 8-May-2009 [13682] | I think its a good idea to ahve find like that (so that it gives subset) but expression would have to be a block so you can put any code inthere and things are systematic |
Maxim 8-May-2009 [13683] | but even extract creates a new series, we just want to change the offset, its much more efficient in all cases... and yess I would have used that VERY often. |
[unknown: 5] 8-May-2009 [13684] | I think everyone would use it very often. I can't believe we haven't created it yet. |
Maxim 8-May-2009 [13685x2] | basically its exactly like sort's /compare argument. |
like /skip, maybe the /compare refinement could become more generalized. this would be a logical complement to the flat record concept which /skip enables... wrt SQL, in some cases /compare is used as a where clause, other times its the argument to TOP, somethimes its used as the ORDER-BY, its very symmetric and much simpler to have the same refinement for all of these IMHO | |
[unknown: 5] 8-May-2009 [13687] | Would be nice to add that functionality to those other functions that could use it. |
kcollins 8-May-2009 [13688] | So the desired feature is to return the series at the position of the first element which meets a specified condition? |
[unknown: 5] 8-May-2009 [13689x2] | yes. |
since find already has /reverse that would be nice to have it use that as well such as: find/reverse series > 3 | |
Maxim 8-May-2009 [13691] | there some details to consider for string parsing though... |
older newer | first last |