logoalt Hacker News

mpweihertoday at 6:41 AM0 repliesview on HN

I think there is a good case to be made for these things not to be mediated by the operating system by default.

In Objective-Smalltalk[1], I can access a file as follows:

   hello ← file:hello-world.txt 
This is structurally the same way I would access a local variable, environment variable, database, remote http server etc.

   hello ← https://example.com/hello-world.txt
   hello ← env:GREETING
   hello ← var:greeting         //   hello defaults to var:hello
etc.

And you can also introduce shortcuts

   scheme:greeter ← ref:https://example.com/ asScheme.
   hello ← greeter:hello-world.txt
Or

   scheme:greeter ← ref:file:./ asScheme
   hello ← greeter:hello-world.txt
Sending -asScheme to a reference is just a shorthand that actually constructs a composition[2] of a "path relative" store with the underlying store of the original reference. So the following two are identical:

   scheme:greeter ← ref:https://example.com/ asScheme.
   scheme:greeter ← #MPWRelativeScheme{ base: 'https://example/com' } → #MPWURLSchemeResolver{} 
This composition mechanism can be carried further with post-processing, so for example an img-scheme can be constructed by composing an image-decoder store with the previous store

   scheme:img ← #MPWImageDecoderStore{} → scheme:greeter 
   helloPic ← img:wave.png 
And so on and so forth, caching is also a nice example.

[1] https://objective.st

[2] https://dl.acm.org/doi/10.1145/3359591.3359729