World: r3wp
[!REBOL3-OLD1]
older newer | first last |
Maarten 31-Aug-2006 [1192] | I'll add a fourth non-english native; rejoin is fine with me, wasy to remember as reduce-join. |
Henrik 31-Aug-2006 [1193x2] | I had a few problems with 'join and 'rejoin in the beginning because I somehow expected them to be a bit like form and reform, using the same arguments as input. That's of course not logical, but I think that the 'word and 're-word naming of functions, doesn't entirely fit and actually limits the naming scheme, making it a disadvantage rather than an advantage. Does 'recycle have anything to do with 'reduce? Or 'remove? No. One might think up a 'move function that does 'reduce. That would clash with 'remove, but 're- has two different meanings. Words in rebol usually have sensible naming, something you can pick out of the dictionary and it'll make sense, except for those with 're- in front of them. If you take them out of context and try to explain them, you have to know about 'reduce, but the dictionary meaning of the 're- words is something different. I don't have any suggestions on how to change this though, other than add a dash: re-form, re-join, re-mold...:-) |
Which brings me to another topic: dash. This can be a little painful in text editors, because a dash usually always has arithmetic meaning, no matter where you write it in other languages. But in REBOL, dashes not prefixed and postfixed with a space, have the same meaning as underscore or other word separation character. This means that in text editors, I can't double click to select a word and probably more importantly for some code editors, I can't autocomplete the word. Of course I could stop using dash myself, but there are a lot of system words with dashes in them, such as 'sendmail-pref-file or 'dsa-verify-signature. So I sit in the code editor and type. But was it 'verify-dsa-signature or 'dsa-verify-signature? Darn it, have to look it up, because the text editor can't complete the word! | |
Anton 31-Aug-2006 [1195x2] | How about taking a page from Andrew Martin's book: rename REJOIN -> JOINS ? ie. JOIN joins two arguments, JOINS joins any number of arguments. Or it could also be ENJOIN (N-JOIN). |
I think the Francophones would also like ENJOIN. | |
JaimeVargas 31-Aug-2006 [1197x5] | Why not simply get rid of rejoin and replace for the more useful DELIMIT? |
delimit [1 2 3] ;== "123" delimit/with [1 2 3] "," ;== "1,2,3" delimit/quoted [1 2 3] ;== {"1","2","3"} delimit/quoted/with [1 2 3] "|" ;== {"1"|"2"|"3"} npa: 703 nxx: 938 delimit [npa nxx] ;== "npa nxx" delimit/reduce [npa nxx] ;= "703938" delimit/reduce/with [npa nxx] "-" ;== "703-938" delimit/reduce/quoted/with [npa nxx] "|" ;== {"703"|"938"} | |
Sorry for that it drives me nuts that Altme in OSX doesn't preserve newlines. | |
;; usage examples delimit [1 2 3] ;== "123" delimit/with [1 2 3] "," ;== "1,2,3" delimit/quoted [1 2 3] ;== {"1","2","3"} delimit/quoted/with [1 2 3] "|" ;== {"1"|"2"|"3"} npa: 703 nxx: 938 delimit [npa nxx] ;== "npa nxx" delimit/reduce [npa nxx] ;= "703938" delimit/reduce/with [npa nxx] "-" ;== "703-938" delimit/reduce/quoted/with [npa nxx] "|" ;== {"703"|"938"} | |
;; Here is my implementation, maybe in can be fine tuned. delimit: func [data [block!] /reduce /quoted /with separator [string! char!] /local result quote][ unless empty? data [ result: copy {} unless with [separator: ""] quote: either quoted [ func[x][rejoin [{"} x {"}]] ][ func[x][x] ] insert result quote form either reduce [do first data][first data] foreach value next data [ insert insert tail result separator quote form either reduce [do value][value] ] result ] ] | |
Anton 31-Aug-2006 [1202] | It looks like a very fine function - *except* I would name it differently (I prefer GLUE). |
JaimeVargas 31-Aug-2006 [1203] | I think the form use to produce the reduce effect is incorrect. Most probablay it needs to written using DO/NEXT. |
Anton 31-Aug-2006 [1204x2] | Lots of English candidate words suffer because they don't imply copy, whereas in rebol this is important and it would be nice to distinguish between when we are copying and when we are not. |
I think you are right. FOREACH is stepping through each value of the block unevaluated, then, expecting to be able to evaluate it successfully. But what if it is a function expecting arguments ? | |
JaimeVargas 31-Aug-2006 [1206x2] | ;; New version does proper reduction delimit: func [data [block!] /reduce /quoted /with separator [string! char!] /local result quote][ if reduce [data: system/words/reduce data] unless empty? data [ result: copy {} unless with [separator: ""] quote: either quoted [ func[x][rejoin [{"} x {"}]] ][ func[x][x] ] insert result quote form first data foreach value next data [ insert insert tail result separator quote form value ] result ] ] |
;; example >> delimit/reduce/with [npa nxx square-root 4] " " ;== "703 938 2.0" | |
Anton 31-Aug-2006 [1208] | Note, if this is going to be Rebol3, then you should be able to use APPEND instead of INSERT TAIL without penalty. |
JaimeVargas 31-Aug-2006 [1209x6] | Now we need a good name. I am not sure about glue. How about CONCAT |
Another one is CHAIN | |
concatenate: verb [ trans. ] formal or technical link (things) together in a chain or series : some words may be concatenated, such that certain sounds are omitted. | |
Another optin is LINK | |
To summarize we have: REJOIN, GLUE, CONCAT, CONCATENATE, CHAIN, LINK. | |
And DELIMIT | |
Henrik 31-Aug-2006 [1215x3] | 'link? is already used, so it might be interpreted as 'link is somehow ... linked to 'link? :-) |
interpreted as if 'link is | |
weld? | |
Anton 31-Aug-2006 [1218] | Just looking at the Thesaurus: http://thesaurus.reference.com/search?q=join&x=0&y=0 Some nice words: adhere, affix, (agglutinate), cement, conjoin, fasten, fuse, leash, marry, wed, weld. |
JaimeVargas 31-Aug-2006 [1219] | Do you want the added functionality of the DELIMIT above? |
Henrik 31-Aug-2006 [1220] | jaime, yes that would be very nice |
Anton 31-Aug-2006 [1221x3] | conjoin is cool, language root are like "delimit/with" |
Ah yes, Jaime, I wanted to say "DELIMIT" lies to you when it is used without the /WITH refinement, because DELIMIT implies delimiters. If there aren't any delimiters, then it is lying. | |
So an idea I would like to explore is to split the functionality of DELIMIT into perhaps two functions. As this kind of operation is very common, I suggest that this will save lots of typing. | |
JaimeVargas 31-Aug-2006 [1224x2] | How will you split it. |
The description I have for DELIMIT is "Returns a string! constructed from the chained values in the block." | |
Anton 31-Aug-2006 [1226] | Must think about that. |
JaimeVargas 31-Aug-2006 [1227x2] | I should not that I am not attached to DELIMIT. It stated like with a different purpose, but now I see that is more generic than REJOIN. So I offer it after modifying it a bit. |
I like the CONJOIN word. | |
Anton 31-Aug-2006 [1229] | Currently we use REJOIN for most things, and sometimes we miss being able to add delimiters, after that, the next functionality is probably the quoting. |
JaimeVargas 31-Aug-2006 [1230x2] | But CONJOIN is not very common. I thinkn CONCAT will be more mnemonic for newbies. |
Picking names is very hard. I kind of like to have all the functionality cram in one function, less words to remember. So I left the naming decision to the community, just hope the features of delimit are include in R3. | |
Anton 31-Aug-2006 [1232x2] | So I would drop the /WITH refinement and make it implicit in a DELIMIT or CONJOIN function... (maybe..) 1) rejoin/quoted [...] ; <-- this is most similar to rejoin, or delimit without the /WITH 2) conjoin/quoted "," [...] ; <-- this is like delimit/with/quoted (and the non-optional "with" argument is specified first) |
I dislike CONCAT because it is an abbreviation. | |
JaimeVargas 31-Aug-2006 [1234x2] | me too, but a lot of people knows it. |
I am not sure I follow your points. | |
Anton 31-Aug-2006 [1236] | The first function, REJOIN, is like the current rebol REJOIN, except it now has your /QUOTED refinement. |
JaimeVargas 31-Aug-2006 [1237] | I don't really see the reason for splitting features of the function. |
Anton 31-Aug-2006 [1238] | The second function, CONJOIN, is like your DELIMIT, except with WITH refinement implicit. |
JaimeVargas 31-Aug-2006 [1239] | I think is better to keep Rebol's lexicon short. |
Anton 31-Aug-2006 [1240] | I think the /REDUCE refinement usually isn't needed (I could be wrong), because if you are not going to reduce the block then you already know what the result is. |
JaimeVargas 31-Aug-2006 [1241] | >> delimit [1 1 / 2 ] ; == "11/2" >> delimit/reduce [1 1 / 2] ; == "10.5" |
older newer | first last |