World: r3wp
[!REBOL3-OLD1]
older newer | first last |
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" |
Anton 31-Aug-2006 [1242] | I think functions that are used very often with certain combinations of refinements ought to be split. |
JaimeVargas 31-Aug-2006 [1243] | That can be changed easily. |
Anton 31-Aug-2006 [1244] | If we make the right decisions about which functions are important enough to have their own word, we free ourselves with clearer code etc. Imagine if there was no DO function, but that functionality was a refinement of LOAD or REDUCE ---> We would write REDUCE/DO all the time. |
JaimeVargas 31-Aug-2006 [1245] | The default behaviour could be to reduce. |
Anton 31-Aug-2006 [1246] | That might be an idea. Closer to current rebol behaviour too. |
JaimeVargas 31-Aug-2006 [1247] | delimit [1 1 / 2] ;== "10.5" delimit/literal [1 1 / 2] ;== "11/2" |
Anton 31-Aug-2006 [1248x2] | Yes, I think that's better. That refinement is the "weakest" of the three. |
Please excuse me if I'm a little hazy today. Feeling a bit quantum mechanical today. | |
Tomc 31-Aug-2006 [1250] | I like 'conjoin |
Henrik 31-Aug-2006 [1251] | anton, don't go phase into higher dimensions jus yet. :-) |
Anton 31-Aug-2006 [1252] | it is ... too late... for me... |
Pekr 31-Aug-2006 [1253x2] | but then also think about form vs reform |
wasn't there supposed to be kind of formatting dialect at one time? IIRC Carl never added it to rebol. Maybe 'form could be used even for joining, although its purpose is slightly different. | |
Oldes 31-Aug-2006 [1255] | I think, there are more important issues than renaming rejoin |
Pekr 31-Aug-2006 [1256] | :-) |
Anton 31-Aug-2006 [1257] | Well, I agree, but it's worth consideration when taking a break from work. Rejoin is pretty close to the core. So if we can improve it, that would be great. |
Pekr 31-Aug-2006 [1258] | as for us, there are no issues, unless we have something to test in our hands .... which seems being slipped to some late fall imo .... |
Anton 31-Aug-2006 [1259] | adjoin: func [ data [block!] /literal /quoted /local result ][ unless literal [data: reduce data] result: copy {} foreach value data compose [ insert tail result ( either quoted [ [rejoin [{"} form value {"}]] ][ [form value] ] ) ] result ] ; test adjoin [] adjoin [1 + 2 3 + 4] adjoin/quoted [1 + 2 3 + 4] adjoin/literal [1 + 2 3 + 4] adjoin/literal/quoted [1 + 2 3 + 4] conjoin: func [ separator [string! char!] data [block!] /literal /quoted /local result process ][ unless literal [data: reduce data] result: copy {} process: func [x] either quoted [ [rejoin [{"} form x {"}]] ][ [form x] ] unless empty? data [ insert result process first data ] foreach value next data [ insert insert tail result separator process value ] result ] ; this way inlines more code, could be faster conjoin: func [ separator [string! char!] data [block!] /literal /quoted /local result process ][ unless literal [data: reduce data] result: copy {} process: func [code][ compose/deep either quoted [ [rejoin [{"} (code) {"}]] ][ [(code)] ] ] unless empty? data compose [ insert result (process [first data]) ] foreach value next data compose [ insert insert tail result separator (process [form value]) ] result ] ;test conjoin "," [] conjoin "," [1 + 2 3 + 4] conjoin/quoted "," [1 + 2 3 + 4] conjoin/literal "," [1 + 2 3 + 4] conjoin/literal/quoted "," [1 + 2 3 + 4] |
JaimeVargas 31-Aug-2006 [1260x3] | Anton, I really don't see the need for having ADJOIN and CONJOIN. There is a lot of code repetition for little gain in expresiveness. |
Besides enlarging the lexicon. | |
Also, your implementation is slower than DELIMIT, by an order of magnitude. >> time-block [conjoin "," []] 0.05 ; == 4.953515625E-5 >> time-block [delimit/with [] ","] 0.05 ; == 2.453125E-6 | |
Volker 31-Aug-2006 [1263] | to-string does joining already, but not reducing. How about restring? Looks ugly, but clearer? |
BrianH 31-Aug-2006 [1264] | I like conjoin, although I'd put the delimeter after the data block. I don't like restring as I'd use this to build blocks too. |
Anton 1-Sep-2006 [1265x2] | Jaime, I think my second version of conjoin performs much better with non-empty input blocks. :) I don't see how my inlined code can be slower than your function call overhead, except for very short input data. |
I still feel I would enjoy having two functions here (adjoin, conjoin), so I think we just have to agree to disagree. It is a matter of taste. But, since there are benefits and advantages to each choice, and the choices are closely matched (to my eyes, at least :), then it does not matter which we choose. Flip a coin, or keeping arguing until the other guy gets tired. :) | |
BrianH 1-Sep-2006 [1267] | When I said I like conjoin, I meant the word "conjoin". I think it woud be a good name for the ONE function that would perform a useful subset of all of the tasks that have been specified here as part of the various functions suggested here, starting with Jaime's delimit, but with the delimiter mandatory. We already have a verson of delimit without the delimiter - it's called rejoin. |
Anton 1-Sep-2006 [1268] | Yes, actually my ADJOIN doesn't look as useful as my CONJOIN; it's quoted refinement would probably not be useful as is. It can be improved but since CONJOIN does everything, maybe better ADJOIN be dropped. |
BrianH 1-Sep-2006 [1269x4] | In particular, I would need to be able to process blocks or lists or some such and have results of the same type. Basically the same behavior as rejoin, but with a delimiter. "Conjoin" means "join with". That /quoted refinement seems interesting though, when you are conjoining strings. |
To me, delimit would intersperse the delimiter in the block but not join it. That what the word suggests, at least. | |
Anton, I'd drop the word "adjoin" because it means basically the same thing as "join". | |
Jaime, your /reduce refinement would seem to be less efficient than reducing the data before passing it to your function, by one comparison. | |
JaimeVargas 1-Sep-2006 [1273x3] | CONJOIN is good, and Brian maybe right regarding droping the reduce refinement. So that [conjoin/reduce...] becomes the idiom [conjoin reduce ...] |
One thing though Ladlislav is suggesting to remove REJOIN. | |
Either by replacment or renaming. | |
older newer | first last |