4 ms·
Thanks! And oh, for longer discussions do pop in on gitter, gokr/spry. Some attempts at answers: Yes, the select: there is not polymorphic, it's simply a funct
by gokr 10y ago
Thanks! And oh, for longer discussions do pop in on gitter, gokr/spry. Some attempts at answers:
Yes, the select: there is not polymorphic, it's simply a function (as of right now).
clone is a primitive function, can be seen here:
https://github.com/gokr/spry/blob/master/src/spryvm.nim#L1804 https://github.com/gokr/spry/blob/master/src/spryvm.nim#L180...
(search for "clone" on that page to find the Nim implementations for the various basic node types)
whileFalse: is also a primitive and can be seen here:
https://github.com/gokr/spry/blob/master/src/spryvm.nim#L1904-L1911 https://github.com/gokr/spry/blob/master/src/spryvm.nim#L190...
So yes, these are examples of primitive Spry functions that are implemented in Nim.
Regarding the larger question, you can implement control structures in Spry, but they are obviously quite a lot slower. Also, it's worth noting that whileTrue: and friends are normally in Smalltalk implemented using special case bytecode tricks (jump).
But you are correct in wondering about polymorphism, and Rebol doesn't AFAIK have anything like it - Carl shunned OO when creating Rebol. In Spry I am working on a concept of tags and what I call polyfuncs. Any node can have one or more tags added to it and functions can have multiple sub functions dispatched over based on these tags. The basics of this already works:
https://github.com/gokr/spry/blob/master/src/sprytest.nim#L458-L459 https://github.com/gokr/spry/blob/master/src/sprytest.nim#L4...
Hard to read I guess, but it basically creates a polymorphic function "inc" that has two different sub funcs selected based on the tag of the receiver.
So about "design principle" - both yes and no. Spry is more "shallow" than typical Smalltalks because Spry is being implemented much more tightly together with Nim. This is by design, it makes it MUCH easier to make primitives and to interface with Nim and thus also C/C++. It's already trivial to do, and a lot of the examples show that. But I also want Spry to feel similarly "coherent" as Smalltalk does.
And yes, definitely will describe the block/list thing in the manual. Too bad this HN post happened before the manual is out there, but oh well.
But generally this is what homoiconicity means - code is in the same format as the core data structures. You can thus create and manipulate code as lists - just as in Lisp.
- draegtun 10y ago>> ...about polymorphism, and Rebol doesn't AFAIK have anything like it - Carl shunned OO when creating Rebol. Rebol does have objects, that's what the O in Rebol refers to. Their prototypal objects influenced by the Self language. And it also has polymorphism "built-in" [1] via its datatypes. However there doesn't seem to be a mechanism to extend or add your own. I guess the plan was probably to make use of the utype! datatype [2] penned for Rebol 3. I think Carl Sassenrath is fine with OO but just doesn't like how most OO languages work [3]. [1] action! datatype - http://www.rebol.com/r3/docs/datatypes/action.html http://www.rebol.com/r3/docs/datatypes/action.html [2] utype! - http://stackoverflow.com/questions/26780398/whats-known-about-utype-in-rebol-3 http://stackoverflow.com/questions/26780398/whats-known-abou... [3] The problem with OOL is not the OO - http://www.rebol.com/article/0425.html http://www.rebol.com/article/0425.html
- gokr 10y agoWell, when I talk about polymorphism I of course mean the ability in the language to create first class polymorphic constructs. Hardwired things like [1] doesn't count :) Further, I had read the article [3] and it seems to me that he indeed "rejected" OO in large parts after having worked with Smalltalk. That's quite intriguing (or astounding!) to me - since I agree that most so called OOP languages misses a lot of the story when compared to Smalltalk. Personally I find polymorphism and encapsulation together with strong abilities of abstraction to be the key aspects of OO and I have never found any language that captures these things better than Smalltalk. At the same time I also find Rebol's focus on DSLs to be very interesting - and as many may know this was also a big part of Alan Kay's FONC project. In Spry I want to combine both. In contrast to Carl I embrace the original ideas of OO as manifested in Smalltalk. However, I couldn't care less of a lot of the overcomplicated mess that so called other OOP languages have created since then, and I also think the beauty of Smalltalk can be captured differently, for example without classes.