World: r3wp
[Core] Discuss core issues
older newer | first last |
Ladislav 25-Jul-2010 [17666] | Neverthless, the meaning of "combined operators" like [a | b & c] may become unclear quickly |
BrianH 25-Jul-2010 [17667] | Especially when combined with the new treatment of setwords. |
Graham 25-Jul-2010 [17668] | Steeve, Gab already has nforeach .. .I was just looking to reduce the number of functions exposed |
BrianH 25-Jul-2010 [17669] | We are doing that is other ways, mostly by paring down the number of included-by-default non-native functions to just what the system needs, and putting the rest into optional utility modules. (I assume you were proposing this for R3, since R2 is in maintenance mode.) We are also encouraging this kind of thing to go into community libraries. However, there is currently a missing feature in R3 that makes mezzanine loop functions rather difficult to write (no RETURN or EXIT passthrough), so any added loop functions are *definitely* not going into the system until that is resolved. |
Graham 25-Jul-2010 [17670x2] | I was just asking for this just for language purity .... I don't care if we never see it or not. |
maybe it can be done using some hof instead .. Ladislav's suggestion breaks current behaviour | |
Ladislav 25-Jul-2010 [17672] | breaks current behaviour - much less than any of yours, actually |
Gabriele 26-Jul-2010 [17673x2] | the thing is... would you want the more generic foreach to automatically reduce the second argument? 90% of the time you need reduce there; but, then you have foreach reducing or not depending on the first argument... and so on. there are a lot of subtle problems; i think it's simpler to have a more generic function and keep the simpler foreach. (alternatively, but this breaks compatibility, make foreach generic and use repeat for the simpler case) |
the only problems i have with my nforeach are: i don't like the name, and the implementation is more complicated than i'd like it to be (though, it should be better in R3). | |
Graham 26-Jul-2010 [17675] | forneach is better? :) |
Gabriele 26-Jul-2010 [17676] | foreachn ? lol |
Graham 26-Jul-2010 [17677] | I could live with that ... it reads the best |
Henrik 26-Jul-2010 [17678] | forsome |
Graham 26-Jul-2010 [17679] | foursome? |
Henrik 26-Jul-2010 [17680] | Graham, this group is web public :-) |
Graham 26-Jul-2010 [17681] | I was just correcting your spelling! |
BrianH 26-Jul-2010 [17682] | It's a compound word. The FOR* group omits the hyphens, so FORSOME means FOR-SOME. |
PeterWood 26-Jul-2010 [17683] | forevery ? |
Izkata 26-Jul-2010 [17684x2] | formulti ? |
(as in "multiple", not "multiply") | |
Steeve 26-Jul-2010 [17686] | forfor |
Maxim 26-Jul-2010 [17687x2] | forsome is really nice. I like the pun it goes well with the language (and its community) not taking itself too seriously. |
the name is actually quite appropriate, since the dialect defines what is run or not... which implies that only SOME of the data will be operated on. | |
Steeve 26-Jul-2010 [17689] | mine is shorter, and is specialy suited to win further puzzles :-) |
Gregg 26-Jul-2010 [17690x2] | traverse [ all blk-n each [a b] blk-a skip blk-x 2 each e blk-e ][ ;... ] |
Hmmm, what if you had a body block for each item in the dialect, so the main body is the innermost loop. Interesting to think about anyway. | |
Gabriele 27-Jul-2010 [17692x3] | Gregg, the issue becomes, do you want all of them to advance at the same time, or nested, and if nested, in which order? |
I'd say that nested cases are already well handled by what we have so they can be ignored. | |
So... I guess your idea is not bad at all. | |
Graham 3-Aug-2010 [17695x7] | I wonder if there is a way for 'if to not return a value? |
I'm looking for a pass thru mode if 'if is false | |
eg. if I want to avoid the #[none] >> print rejoin [ "hello " if false [ "world" ]] hello none >> print rejoin [ "hello " either true [ "world" ]["" ]] hello world | |
>> print rejoin [ "hello " if/only false [ "world" ]] hello | |
so something like that ... | |
This is the construct I saw which I don't like either true [ tail s ][s ] which I could then replace with if/only true [ tail ] s | |
It's less verbose and possibly clearer than using the 'either construct | |
Maxim 3-Aug-2010 [17702x3] | if/else false [][#[unset!]] |
>> only: func [c b][if/else c b [#[unset!]]] >> only true ["howdy"] == "howdy" >> only false ["howdy"] | |
is this what you need? | |
Graham 4-Aug-2010 [17705] | Nope .. >> print rejoin [ "Hello " only false [ "world" ]] Hello ?unset? |
Maxim 4-Aug-2010 [17706x4] | functions which don't return anything actually return unset! |
rejoin is the culprit here. the only reason your tail s works is because you are appending an empty block to a string, which = to appending an empty string to a string. | |
ex: >> rejoin ["" prin ""] == "?unset?" | |
IIRC R3's rejoin now ignores the unset values | |
Graham 4-Aug-2010 [17710] | I just want if/only to drop a value off the stack if false |
Maxim 4-Aug-2010 [17711] | only: func [c b][if/else not c b [#[unset!]]] you can reverse the truth, but you will always return unset! there is no such thing as a function which doesn't return a value in REBOL. |
Graham 4-Aug-2010 [17712] | I want to avoid these 'none values ... where you are forced to use 'either |
Maxim 4-Aug-2010 [17713x2] | well, you have to chose between unset! or none!, but R2's rejoin collects the unset values and appends them to strings (which is a bit dumb). |
you can also use compose, which ignores unset! values. >> reduce compose ["" (prin "")] == [""] | |
Graham 4-Aug-2010 [17715] | that's for rejoin ... which is just one example |
older newer | first last |