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

[REBOL] Re: file bug?

From: rotenca:telvia:it at: 9-May-2003 22:08

Hi Hugues, 1) Rebol data are stored in memory with an unknown format. 2) When you save a block or mold a block, all values in memory are converted in a string (serialized). 3) This kind of string can be interpreted by the function Load (and Do) to convert the string in a sequence of Rebol values in memory.
> when i do this : > >> load "%s%40a" > == %[s--a] > > I get the evaluation of the string, which is converted to a file datatype.
When Load find in a string datatype a sequence of byte which starts with %, Load tries to convert it in a file datatype! Every %xx sequence is interpreted like a single char where xx is the hex number representation.
> when i do this: > >> load %s%40a > == [l1: 1 > l2: 2 > l3: 3 > l4: 4 > l5: 5 > ] > > I get the content of the file.
When you pass a file datatype (not a string datatype), Load read the file and tries to interpret its content like a string.
> when i do this > >> load %[s--a] > ** Syntax Error: Invalid email -- %[s--a] > ** Near: (line 1) load %[s--a] > > I get an email address evaluation, when i want a file.
You must think that when you type a sequence of chars in the console, you are writing a string which is auto-magically loaded and then interpreted, so:
>>Load %[s--a]
must be seen like a sort of: do load "Load %[s--a]" The first Load interprets the string "Load %[s--a]" and finds in it a word: load and then the sequence: %[s--a] because this sequence does not start with " or { and contains the char @, Rebol interprets it like an email address. We could say that email has precedence on file. Load tries to create now a small Rebol program: symbol datatype! Load word! %[s--a] email! but %[s--a] is an invalid email symbol -> error! If you want a file name with a @ in it, you can use "":
>> type? %"[s--a]"
== file! or %40
>> type? probe %s%40a
%[s--a] == file!
> >> load %sa.txt > ** Access Error: Cannot open /c/rebol/view/sa.txt > ** Where: halt-view > ** Near: load %sa.txt > > I get an error because te file does not exist. So the word %sa.txt as been > evaluated to a file!
yes, because it does not contain @ and starts with %
> So, what i know of rebol is that it evaluates the words. the load command > needs either a file, or a url or a string. And in the rebol documentation > i've read that the files are recognized by a percent just before the path of > the file. > What i don't understand is why the part just after the percent is evaluated > whereas it's just a path in the file syntax.
Because also email can have %xx sequences in it:
>> [%63arl--rebol--com]
== [carl--rebol--com]
>> type? [%63arl--rebol--com]
== email!
> Another thing : > when i do this : > >> do %sa > ** Syntax Error: Script is missing a REBOL header > ** Where: halt-view > ** Near: do %sa > I get an error because rebol want a script, but the %sa has been evaluated a > a file.
No, because exists a file in your current dir called "sa" which does not contain a standard rebol header (Rebol []) Hope it helps. (my English is bad) --- Ciao Romano