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

[REBOL] Re: file bug?

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