proposed WebDAV mapping
So I’ve got a class called “Spoon” which services requests about Spoon from the rest of the world, via WebDAV. In particular, I provide the illusion of a filesystem that can be mounted by other operating systems. Editing certain of those virtual files invokes behavior within Spoon.
Here’s a summary of that filesystem:
/ /bin/ (frequently-used expressions, presented as executable files) /classes/ (all the classes) ... /classes/<class>/ (a file for each method of <class>) /do (a file to which one write a method, which is then executed, leaving the result as the file contents) /notes/ (a normal directory, for use as a staging area for "do" files, for example)
Here’s what you might see at a shell on a machine which has a mounted Spoon system:
craig@netjam spoon> pwd /Volumes/spoon craig@netjam spoon> ls classes/ notes/ do craig@netjam spoon> cd classes craig@netjam classes> ls Object/ craig@netjam classes> cd Object craig@netjam Object> ls Boolean/ Collection/ (etc.) craig@netjam Object> cd Boolean craig@netjam Boolean> ls and: ifFalse: ifTrue: (etc.) craig@netjam Boolean> more ifTrue: ifTrue: aBlockClosure "If I am true, answer the value of aBlockClosure. Otherwise, answer nil." self subclassResponsibility craig@netjam.org Boolean> cd /Volumes/spoon craig@netjam.org spoon> echo "3 + 4" >! do craig@netjam.org spoon> more do 7 craig@netjam.org spoon> cd /bin craig@netjam.org bin> ls snapshot (etc.) craig@netjam.org bin> snapshot
This seems like the minimal functionality. What else would be nice or fun to have?
3 June 2011 at 2:06 am
/bin/senders /Classes/Object/printOn:
/bin/implementors /Classes/Object/printOn:
/bin/references /Classes/Object
/bin/smalllintMessagesSentButNotImplemented
rm –safely someMethod
# next line: refactoring browser’s push method up
mv printOn: ..
LikeLike
3 June 2011 at 7:54 am
Good ideas!
LikeLike
3 June 2011 at 5:33 am
Hi Craig,
that looks like a very interesting idea. I have just a small concern about this do file. Why would you replace the file content by the result instead of putting the result in a /result file? That might no be a problem, but it looks suspicious.
Is it possible to pass parameters to the executables in /bin?
If you introduce packages/categories in Spoon, it might be worth reflecting this in a new entry point (e.g., /packages/collections/arrayed/Array). Same thing for protocols (e.g., /…/aClass.protocols/accessing).
Do you also plan to access/modify objects in this filesystem?
Going a bit further, do you think it could be possible to implement a Smalltalk application by only using Bash syntax?
LikeLike
3 June 2011 at 12:06 pm
Yeah, a /result file makes sense.
Sure, one could pass parameters to the bin executables. I like Bob’s example above.
Oh yes, there are a lot of things to be done with Naiad modules and module/class/method/author tags.
I’d like to be able to manipulate individual objects as well, but I’m not sure how yet. I think being able to write a Smalltalk application as a shell script would be fun, in a twisted way. :)
LikeLike
3 June 2011 at 10:26 am
Not sure how the /bin directory would work. Reading a file from there would execute it? Because this is a regular shell, right? The filesystem would only see the read request. So no arguments. Unless you cleverly return an actual executable that somehow works on that platform and does something incredibly clever? IMHO this looks like taking the idea too far ;)
LikeLike
3 June 2011 at 11:56 am
Oh, good point. I guess every command could be a directory instead of a file, and you could write the arguments into a special file in the directory (it could even be a form you fill out). Clunky, but it could work.
LikeLike
3 June 2011 at 12:27 pm
I think it would be a good idea to learn from Linux’s /proc interface. This is how you interact with the kernel through a files system, writing into and reading from what looks like files. The files are created by the system.
OTOH I am not sure you actually need more than the “do” mechanism, it can execute any message, right?
echo 3 + 4 > do ; cat do
echo Smalltalk snapshot > do
For more fancy interaction you could have a web browser interface.
Or for geek cred, a telnet interface.
LikeLike
3 June 2011 at 11:44 am
Instead of replacing the contents of a special file name, why not use STDIN/STDOUT?
craig@netjam.org spoon> echo “3 + 4” | bin/doIt
craig@netjam.org spoon> echo “3 + 4” | bin/printIt
7
LikeLike
3 June 2011 at 12:08 pm
Hm, I guess that’s another one that would require a special shell, too bad.
LikeLike
8 June 2011 at 4:37 pm
Look at plan9 – the quintessential way to use pseudo-files to control the world.
http://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs#Unified_input.2Foutput_model
and maybe
http://swtch.com/plan9port/man/man1/intro.html
LikeLike