World: r3wp
[!REBOL3-OLD1]
older newer | first last |
Ladislav 31-Aug-2006 [1176x2] | My point of view is, that in this case REBOL behaves as Weakly Typed Language, because REPEAT considers any value to be integer. |
Anbody with an inspiration having a perfect (or at least better) name for REJOIN? | |
Oldes 31-Aug-2006 [1178] | why? maybe GLUE? |
Ladislav 31-Aug-2006 [1179x2] | Re REPEAT once again - I should rather have said, that REPEAT was Type Unsafe in this case |
GLUE - sounds interesting | |
Oldes 31-Aug-2006 [1181] | but what's wrong with REJOIN? |
Pekr 31-Aug-2006 [1182] | why give rejoin different name? it is reduce join after all? Well, I know that "rejoin" sounds like once again joining something, but maybe re-join |
Ladislav 31-Aug-2006 [1183] | not much except for the fact, that beginners don't know what it means |
Pekr 31-Aug-2006 [1184x2] | reduce-join |
not short, but clear ... | |
Oldes 31-Aug-2006 [1186] | I like REJOIN and never had problem to understand what it means and I don't like longer name for it, I write it too often |
Pekr 31-Aug-2006 [1187] | if we think in an object method/action fashion, it could be element.reduce element.join (or element.add) - simply it is not typical that you combine two methods in one ... |
Oldes 31-Aug-2006 [1188] | but JOIN is reducing as well >> a: 1 b: 2 join "x" [a b] == "x12" |
Pekr 31-Aug-2006 [1189] | interesting :-) |
Oldes 31-Aug-2006 [1190x2] | I think that thw word GLUE would be better for joining objects together, than joining series like strings |
But 3 people, who are not english natives, should not decide, which english names should be used:-)) | |
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." | |
older newer | first last |