REBOL 3.0

A new kind of dir

Carl Sassenrath, CTO
REBOL Technologies
15-Mar-2007 1:44 GMT

Article #0064
Main page || Index || Prior Article [0063] || Next Article [0065] || 6 Comments || Send feedback

In R3, I can now type:

>> read %*.r
== [%del-objs.r %t.r %t1.r %test.r]

Our friend Petr is going to like that, eh? I think he requested it in 1999. Or, was it 1998?

Of course, this little change has big implications. The issue is this: is *.r a directory or a file?

Well, in reality it is neither. There is no file or dir called *.r. It is a selector specification pattern (in fact, a little domain language) that most file systems accept.

So, you ask again: Carl, as far as my script functions are concerned, is *.r a dir or a file?

Hey, don't ask me... instead, ask REBOL:

>> dir? %*.r
== false

Ok, good to know. Not a dir.

But... what if I do this clever little check:

>> port: open %*.r
>> print port/scheme/name
== dir

Ah ha! So it is a dir!

Yes, it has to be, so that the code:

read %*.r

will return a list of files.

But wait, didn't I just say it wasn't a dir? So now maybe you see why it wasn't part of REBOL previously. "Is it a wave or a particle?" It depends on what you need it to be.

To help with this issue, the dir? function now allows a refinement:

>> dir?/any %*.r  ; just like find/any
== true

So, there you go.

If you think we should make this the default behavior for dir? then let me know. Maybe it should be.

But, you and I both know there are more issues lurking. This trivial little change is not so trivial. More to be said; more to be written...

6 Comments

REBOL 3.0
Updated 23-Nov-2024 - Edit - Copyright REBOL Technologies - REBOL.net