Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

'join automatic type conversion

 [1/8] from: alberto::origen::com::mx at: 8-Dec-2005 10:21


Hi all, Someone can explain me why 'join returns a string! when both args are word! ? eg
>> join 'a 'b
== "ab" would not be useful if that instruction returned a 'word? so, I would not need type
>> to-word join 'a 'b
== ab Cheers -- alberto

 [2/8] from: alberto:origen:mx at: 8-Dec-2005 10:39


ah, now is obvious "why?" :)
>> source join
join: func [ "Concatenates values." value "Base value" rest "Value or block of values" ][ value: either series? value [copy value] [form value] repend value rest ] -- alberto On Thu, 08 Dec 2005 10:21:23 -0600, Alberto <alberto-origen.com.mx> wrote:
> Hi all, > Someone can explain me why 'join returns a string! when both args
<<quoted lines omitted: 9>>
> -- > alberto
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

 [3/8] from: antonr::lexicon::net at: 9-Dec-2005 16:13


Yes :), and words are not quite like strings. You cannot just change them; they have to remain unique in a table for fast lookup. Once you have created a word, you cannot "uncreate" it. So increasing or decreasing the length, or changing characters is not allowed. Regards, Anton.

 [4/8] from: jf_allie::hotmail::com at: 9-Dec-2005 17:06


Anton, You said:
>>Once you have created a word, you cannot "uncreate" it.
Does that mean that when you UNSET a word, it is still there in the dictionnary "waiting" and occupying space in memory? jf

 [5/8] from: alberto:origen:mx at: 9-Dec-2005 12:46


Hi Anton, On Thu, 08 Dec 2005 23:13:31 -0600, Anton Rolls <antonr-lexicon.net> wrote:
> words are not quite like strings.You cannot just change them;
with 'join I wasn't trying to change any word, because AFAIK join returns a new value(?), so I thought it could return a new word. BTW I'm ok with the functionality of 'join -- alberto

 [6/8] from: SunandaDH:aol at: 9-Dec-2005 13:49


jf:
> Does that mean that when you UNSET a word, it is still there in the > dictionnary "waiting" and occupying space in memory?
Yes, indeed. And when you hit 8,000 or so (the number varies by version) you can create no more and your session is dead in the water. It's not *as* bad as it sounds: the limit is 8000 *unique* names.....This code uses only three unique names: a b c a : 1 b: 2 c: func [a /local b c][ b: make object! [b: a c: 6] return b/b ] Sunanda.

 [7/8] from: jf_allie::hotmail::com at: 10-Dec-2005 0:06


Sunanda, 8,000 ! that's an unusual number. Is it the number of vine stock on Carl's land? ;-) jf

 [8/8] from: SunandaDH::aol::com at: 10-Dec-2005 3:19


jf:
> 8,000 ! that's an unusual number. Is it the number of vine stock on Carl's > land? ;-)
I was rounding :-) It looks like a power of 2 minus a few:
>> length? first system/words
== 2462
>> forever [to-word join "a" random 100000]
** Internal Error: No more global variable space ** Where: to-word ** Near: to word! :value
>> length? first system/words
== 8062 Where are the 130 that would make it a neat 8192? Only Carl knows. Also, note that it is somewhat worse than my previous message. Of the 8000 (or so) nearly 2500 are used up already by the system. (That result with View. Different numbers with Core) Sunanda.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted