----- Original Message -----
From: <[EMAIL PROTECTED]>
>
> Hi Olivier,
>
> you wrote:
>
> >Do you think that %"" should be accepted as a valid filename ?
> >Personnally I don't think so, because no operating system I know accept
> >that.
> >%"" should return <none>.
> >This would solve many issues with filename handling (split-path,
> >clean-path).
>
> A valid filename and a valid file! datatype are completely different
> concepts. A file! datatype is just a sort of string, and whether that
> can serve as a valid filename is not something REBOL should have to
> worry about. How about this?
>
> >> nasty-file: to file! {echo "clobber" > rebol.exe}
> == %echo%20%22clobber%22%20>%20rebol.exe
> >> write nasty-file "I did it"
> ** Access Error: Cannot open /C/temp/echo "clobber" > rebol.exe.
> ** Where: write nasty-file "I did it"
>
> It's the operating system that decides whether to allow a filename or not.
>
> %"" by itself is not very useful, but how about this:
>
> >> prefix: %X-
> == %X-
> >> join prefix %name.ext
> == %X-name.ext
> >> prefix: %""
> == %
> >> join prefix %name.ext
> == %name.ext
>
> Even a value that by itself is not a valid filename can make sense in
> combination with another value.

I agree with you for that case.

>
> >Another related problem:
> >>> to file! none
> >== %none
> >
> >It should return either the none value (of datatype none!) or %""
(depending
> >on your answer to the previous question).
>
> This behavior can be annoying, but it's fairly consistent. Compare:
>
> >> join "a string: " none
> == "a string: none"
> >> head insert ", a string" true
> == "true, a string"
> >> to issue! file!
> == #file
>
> Your idea of having TO FILE! NONE return the value NONE is not a good
idea.
> TO always returns a value belonging to the datatype specified in its first
> argument (or if that's not possible, an error is produced). To have TO
> return various other datatypes depending on the circumstance would make
> REBOL much more inconsistent.

You convinced me.

>
> Your idea of having TO FILE! NONE return the value %"" makes a lot of
sense,
> but still, what will you do with TRUE, FALSE, or datatypes? It's not
always
> obvious what is the most reasonable value. I personally find the present
> behavior the best. I never intend to convert NONE to a file! , so when
> I do and I see a file name like %abcnone.xyz it's a dead giveaway what
> went wrong. If I just got %abc.xyz and that wasn't what I was expecting,
> it'd be a lot harder to track down the problem.

I agree.
So what do you think of that :
>> to integer! none
== 0
>> to logic! none
== false


>
> See you,
> Eric
>

Olivier.

Reply via email to