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

file bug?

 [1/13] from: rotenca:telvia:it at: 8-May-2003 20:55


Is this a bug?
>> load mold to-file "[s--a]"
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) %[s--a] --- Ciao Romano

 [2/13] from: greggirwin:mindspring at: 8-May-2003 15:48


Hi Romano, RPT> Is this a bug?
>>> load mold to-file "[s--a]"
RPT> ** Syntax Error: Invalid email -- %[s--a] RPT> ** Near: (line 1) %[s--a] Hmmm, I think maybe so. It looks like to-file should be quoting the file name so you get %"[s--a]" - which works by itself - but if you use it in the context of a path (e.g. %/c/rebol/core/[s--a]), you'd want the whole path quoted, though it isn't necessary in that case. Worth a feedback I'd say. Whatever the case, we need to know how they suggest we deal with this kind of thing. E.g. do we need to escape all chars that would break standard REBOL lexical forms. -- Gregg

 [3/13] from: rotenca:telvia:it at: 9-May-2003 1:52


Hi Gregg
> >>> load mold to-file "[s--a]" > RPT> ** Syntax Error: Invalid email -- %[s--a]
<<quoted lines omitted: 6>>
> suggest we deal with this kind of thing. E.g. do we need to escape all > chars that would break standard REBOL lexical forms.
The problem is that a file name like %[s--a] can be returned by read dir. If I save the name inside a data block, when i try to reload the data, the whole block appears invalid (my block was 600 kb long - sigh). The first solution i see is to transform every filename in a string and the string back to a filename at load time. I think that mold and save should transform: %[s--a] in this molded string: %s%40a so i think that is a mold bug. --- Ciao Romano

 [4/13] from: rotenca:telvia:it at: 9-May-2003 2:26


Hi Gregg Now i see that save/all mold/all don't exhibit the bug. --- Ciao Romano

 [5/13] from: hugues:moisy:geosignal at: 9-May-2003 10:19


Hi Romano, I don't think it's a mold bug because other ways do the same.
>> mold to-file "[s--a]"
== "%[s--a]"
>> rejoin ["%" "[s--a]"]
== "%[s--a]" I get the same result
>> load mold to-file "[s--a]"
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) %[s--a]
>> load rejoin ["%" "[s--a]"]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) %[s--a] I get the same error The problem is that you give a string corresponding to an e-mail evaluation, and it's a problem off load an not of mold Directly with the string i get the same error.
>> load "%[s--a]"
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) %[s--a] And with not string i get the same error It transforms the file to an e-mail!!
>> load %[s--a]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) load %[s--a]
>>
Ciao. Hugues

 [6/13] from: rotenca:telvia:it at: 9-May-2003 14:35


Hi Hugues,
> > I think that mold and save should transform: > >
<<quoted lines omitted: 7>>
> I don't think it's a mold bug because other ways do the same. >> type? probe load "%s%40a"
%[s--a] == file! --- Ciao Romano

 [7/13] from: greggirwin:mindspring at: 9-May-2003 10:50


Hi Romano, RPT> Now i see that save/all mold/all don't exhibit the bug. Ahhh, I always forget about that refinement. Still might be worth a feedback though. -- Gregg

 [8/13] from: hugues:moisy:geosignal at: 9-May-2003 19:39


Hi Romano, To me, the problem is important because whatever i do with %[s--a], i get the same error. Some examples :
>> >> length? %sa
== 2
>> length? %[s--a]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) length? %[s--a]
>> >> file? %sa
== true
>> file? %[s--a]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) file? %[s--a]
>> >> datatype? %sa
== false
>> datatype? %[s--a]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) datatype? %[s--a]
>> >> write/append/lines %sa ["toto"] >> write/append/lines %[s--a] ["toto"]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) write/append/lines %[s--a] ["toto"]
>> >> >> error? write/append/lines %sa ["toto"]
== false
>> error? write/append/lines %[s--a] ["toto"]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) error? write/append/lines %[s--a] ["toto"]
>>
Ciao, Hugues

 [9/13] from: hugues:moisy:geosignal at: 9-May-2003 19:13


Hi Romano, I think i don't understand something with Rebol. Can you explain me, please. when i do this :
>> load "%s%40a"
== %[s--a] I get the evaluation of the string, which is converted to a file datatype. 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 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.
>> load %[s--a--txt]
** Syntax Error: Invalid email -- %[s--a--txt] ** Near: (line 1) load %[s--a--txt] I get an email address evaluation, when i want a file. the Same problem
>> 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! 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. 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.
>> do %[s--a]
** Syntax Error: Invalid email -- %[s--a] ** Near: (line 1) do %[s--a] I get the e-mail error. So i think it's neither a mold problem, nor a load problem, nor a do problem. What i don't understand it's why only a part of a word can be evaluated, before the syntax defining it's datatype. If you can help me. Thanks a lot. Hugues

 [10/13] from: joel:neely:fedex at: 9-May-2003 14:14


Hi, Hugues, LOADing a string asks for the string itself to be evaluated, while LOADing a file asks for the contents of the file to be evaluated. Common REBOL words often behave differently depending on the type of their operands. -jn- Hugues Moisy wrote:
> Hi Romano, > I think i don't understand something with Rebol. Can you explain me, please.
<<quoted lines omitted: 11>>
> ] > I get the content of the file.
-- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Counting lines of code is to software development as counting bricks is to urban development.

 [11/13] 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
<<quoted lines omitted: 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 :
<<quoted lines omitted: 4>>
> 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

 [12/13] from: joel:neely:fedex at: 9-May-2003 14:12


Hi, Hugues, To us a string that contains special characters as a file name, enclose the name (after the % type specifier) in quotes.
>> length? %"[s--a]" == 3 >> file? %"[s--a]" == true >> datatype? %"[s--a]" == false >> type? %"[s--a]" == file!
-jn- Hugues Moisy wrote:
> Hi Romano, > To me, the problem is important because whatever i do with %[s--a], i get the
<<quoted lines omitted: 70>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- ---------------------------------------------------------------------- Joel Neely joelDOTneelyATfedexDOTcom 901-263-4446 Counting lines of code is to software development as counting bricks is to urban development.

 [13/13] from: ingo::h-o-h::org at: 10-May-2003 9:04


Hi Romano, and all, [Resending, because it ddn't make it to the list on the first try ...] Romano Paolo Tenca wrote:
> Is this a bug? > >>>load mold to-file "[s--a]" > > ** Syntax Error: Invalid email -- %[s--a] > ** Near: (line 1) %[s--a]
I'd say it's a symptom of the non-orthogonality of 'mold and 'load (the reason why there is now mold/all and load/all), where 'mold returns data in human readable form sometimes, which 'load is not able to understand any more. What I *guess* happens:
>> load %[a--b]
A human seeing this (and knowing about Rebols conventions for datatypes), would interpret this as a file!, because it starts with a percent sign. Rebol itself sees it as an email!, because it has the at-sign, and emails may contain "%", because it is used to escape characters which normally are not allowed in an email. Now after having decided, that %[a--b] actually is an email!, Rebol tries to "unescape" the percent coded character, but this fails, because for this the percent needs to be followed by two digits.
>> type? %[a--b]
** Syntax Error: Invalid email -- %[a--b] ** Near: (line 1) type? %[a--b]
>> type? [%21a--b]
== email!
>> [%21a--b]
== ![a--b] As already mentioned, there are 2 ways to write the file! which represents the file with the name "[a--b]" on disk. 1) Quote the name
>> %"[a--b]"
== %[a--b]
>> type? %"[a--b]"
== file! Through the quotes Rebol explicitly told to "use this as a filename, whatever characters the string may hold". 2) escape the "@" character
>> %a%40b
== %[a--b]
>> type? %a%40b
== file! Now there is no at-sign in this file name which could fire the email! recongnition. 'mold types both of these like:
>> mold %a%40b
== "%[a--b]"
>> mold %"[a--b]"
== "%[a--b]" which can no longer be understood by load (as seen above), and I guess that in read dir mold is used (or something deeper which causes both the behaviour of mold and read dir). (as a sidenote, in the case of
>> type? %./[a--b]
== file! the presence of the slash, which may not be part of an email! forces this to be understood as a file!) Just my thoughts on this, in a very lengthy email, but why should others have all the fun? ;-) Kind regards, Ingo

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