# NewPath Rising: Call for Examples

#1

A proposal from 2014, before Ren-C existed, was NewPath. (yes, it was a very intentional Scanner Darkly reference)

I was talked out of wacky decomposition of URL! into PATH! with a SET-WORD! at the head, etc. @rgchris convinced me that URLs should be left “as-is”, so you could copy and paste them between the browser and your script. At his direction, Scan_URL was changed to commit more fully to this than Rebol2/Red/R3-Alpha…see the comments there

But I think FILE! is a different case. For one thing, it’s not standardized…spaces are legal, sometimes forward-slashed, sometimes back-slashed. Double quotes are legal even on Windows, basically everything legal on Linux. So if you want to grab a string out of your terminal session and paste it in source, your best bet is pretty much to {W:rap\it in\curly \"braces\".txt}

It seems to me the dream of FILE! achieving something great that TEXT! alone can’t do has not been fulfilled, and is largely un-fulfill-a-ble. Pigeonholing Windows file paths to get stored in formats as %/c/Wherever instead of using "C:\Wherever"…just to get the FILE!-vs-TEXT! datatype bit when you LOAD…seems like a fool’s errand to me–it’s not that great a bit!! If it’s not a manipulable structured PATH! then what was that work for, anyway? You lost the ability to copy/paste into your terminal…and got nothing for your trouble.

My growing suspicion is that we may want to scrap FILE! as a string datatype with weird behavior. Instead, start from a basis of using % as an escape character, to where %foo is just an escaped WORD! and %foo/bar is an escaped PATH!

one-file: %foo/bar.txt
some-files: [
foo/baz.txt
mumble.txt
"Directory With Spaces"/"File With Spaces.txt"
]
alt-one-file: lit foo/bar.txt // LIT would behave like historical QUOTE


Carl himself went down this road. See the %file-list.txt from R3-Alpha When you stop thinking about the percent sign, you perhaps see more opportunities.

## Living in a world without FILE!, but with NewPath

Many ingredients that weren’t around in NewPath’s time are now in Ren-C. PATH!s can feature GROUP!s and BLOCK!s, even in the first element position. You can put arbitrary strings in them, with spaces:

>> load {(a b c)/"d e f"/[g h i]/<j k l>}
== (a b c)/"d e f"/[g h i]/<j k l>


My question is if we can do a thought experiment: pretend you never knew about FILE!, and all Rebol had was TEXT!, generic escaping (consider trying %), and these modern path parts. How satisfied could you be, with what pre-cooked helpers?

Can people find examples of code that manipulates and operates on filenames, and look at that problem from a fresh start? What kind of toolset would build up from it?

>> flag: true
>> root: %foo
>> base: %bar
>> extension: %.txt
>> file-to-local/full %(root)/(subdir)/(if flag [%skip])/[base "." extension]
== "C:\Projects\foo\baz\bar.txt"


It would be a wave of disruption to change % into escaping, that we’re not ready for with an unproven idea. So you’ll have to use your imagination, and pretend backslash or whatever is percent.

I know from experience that this is a problem space fraught with edge cases and issues. The old code has problems, and new code can’t wish them away. But the code has never been in a better position to try and tackle this area with new tricks. So hopefully someone can dig up real examples and NewPath can get the shot it deserves.

#2

I see a similarity with TCL where all is text interpreted by context but it provides functions to build paths in text variable from lists. It’s a try to hide the platform specific format of paths.

#3

It’s been a very long time since I’ve used TCL (> 20 years). If you’re familiar with some relevant examples, could you write a few down to illustrate notable behaviors? If you can post new threads, we have a Foreign Inspiration category…otherwise here is fine.