4 ms·
Thanks! Scheme handlers (or stores[1]) were initially implemented that way. There is a protocol of methods taking references, and you implement these methods,
by mpweiher 8y ago
Thanks!
Scheme handlers (or stores[1]) were initially implemented that way. There is a protocol of methods taking references, and you implement these methods, for example -objectForReference:, with, as you write, runtime parsing of the reference (often, but not necessarily strings).
Having implemented a good number of stores[2] and scheme handlers[3] that way, I can tell you it gets old quick. :-)
Given the emphasis I put on Polymorphic Identifiers in Objective-Smalltalk, it was obvious that I needed better language support for scheme-handlers, generalising the "properties" concept found in many languages now (Objective-C, C#, Swift, Python) with path- and pattern-matching as found in various REST toolkits was one of those in-the-shower epiphanies.
The patterns ( /:table/count ) mean that you don't actually have to have a separate endpoint for each path, you can group semantically related paths as you wish. There is also a wildcard pattern (the asterisk) if you want to just match everything beyond that. So for example:
/property/* { |= { 3.} }
Returns the number "3" for all paths prefixed by "/property".
/property/*:path { |= { path. } }}
Returns the remainder of the path (or you can use it for your own custom matching).
[1] https://github.com/mpw/MPWFoundation/blob/master/Documentation/Stores.md https://github.com/mpw/MPWFoundation/blob/master/Documentati...
[2] https://github.com/mpw/MPWFoundation/tree/master/Stores.subproj https://github.com/mpw/MPWFoundation/tree/master/Stores.subp...
[3] https://github.com/mpw/Objective-Smalltalk/tree/master/Schemes https://github.com/mpw/Objective-Smalltalk/tree/master/Schem...
- saagarjha 8y agoInteresting, I will have to try it out myself when I get some free time. While I don't know Smalltalk very well, from the perspective of an Objective-C developer the way you have designed the project's features is quite fascinating.
- mpweiher 8y ago> don't know Smalltalk very well It's just "Objective-C without the C". Except for real. Mostly just leave out the square brackets and enjoy the unified syntax. > perspective of an Objective-C developer That's my perspective :-) Have been programming in Objective-C for well over 30 years now. I actually started pre-NeXT with my own pre-processor and runtime, had a C compiler and read a lot about OO and really wanted to program that way. Objective-C seemed achievable, and it was.