[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
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
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]
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
>> type? %"[a--b]"
Through the quotes Rebol explicitly told to "use this as a filename,
whatever characters the string may hold".
2) escape the "@" character
>> type? %a%40b
Now there is no at-sign in this file name which could fire the email!
'mold types both of these like:
>> mold %a%40b
>> mold %"[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]
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? ;-)