metaeducation / ren-c

Library for embedding a Rebol interpreter into C codebases
GNU Lesser General Public License v3.0
128 stars 27 forks source link

HELP NEEDED: Transition to MAKE-FILE (%%) #1096

Closed hostilefork closed 4 years ago

hostilefork commented 4 years ago

I've mentioned that it's time to start putting NewPath through its paces. This needs to be discussed, tested, and improved.

It's far from perfect, so replacing old file/path/component cases might hit speedbumps. But those should be studied and then the code and tests adapted to show what it should do.


This moves the MAKE-FILE experimental code that has been used for bootstrap into the main executable. It uses generic PATH! and TUPLE! as a template for composing filenames:

>> extension: "txt"
>> dir: %/home/test/

>> make-file '(dir)/subdir/foo.(extension)
== %/home/test/subdir/foo.txt

There is a shorthand quoting operator tied to the new %% WORD!

>> %% (dir)/subdir/foo.(extension)
== %/home/test/subdir/foo.txt

THE HISTORICAL ABILITY TO PATH PICK A FILE! TO CREATE A FILE! IS GONE.

rebol2>> dir: %/home/test

rebol2>> dir/subdir/foo
== %/home/test/subdir/foo  ; this now fails

MAKE-FILE is not finalized in its abilities, so if using it to replace instances of these calls doesn't seem like it works how it should, it's time to address that.

MAKE-FILE is entirely user code (all extremely draft-level) so it can be worked on. Long term, it will be rethought and rewritten as native code, or at least broken into some support natives that might be more generally useful in PATH! and TUPLE! manipulation.

This commit also includes the beginnings of a SHELL dialect, which needs significant design discussion to decide how it should work:

>> dirs: [%/usr/local %/home]

>> shell [ls -alF (first dirs)]
; acts as `call/shell "ls -alF /usr/local"`

>> $ ls -alF (first dirs)
; variadic operator shorthand for the above