4 ms·
Regarding the "Kingdom of Nouns", I always thought Lobster[0][1] had a really cute idea: x(a, b, c) and a.x(b,c) are equivalent. Don't know if that is original
by vanderZwan 6y ago
Regarding the "Kingdom of Nouns", I always thought Lobster[0][1] had a really cute idea: x(a, b, c) and a.x(b,c) are equivalent. Don't know if that is original to the language, but it's where I saw it first. It only really makes sense with the other features of the language, though.
(Also, I just discovered that it now targets WASM. Maybe I should give it another go!)
[0] http://strlen.com/lobster/ http://strlen.com/lobster/
[1] https://github.com/aardappel/lobster https://github.com/aardappel/lobster
- ar-nelson 6y agoAuthor here: unified function call syntax is awesome but sadly out of scope for what I was trying to do with this language. I mention this in the "Class-based discoverability" section: for the sake of uniformity and IDE discoverability (arguably Java's killer feature that its successors have diluted), I'd want every value and function to belong to a class, which means every nonlocal method call should come after a dot.
- vanderZwan 6y agoThis already assumes that unified call syntax would inherently get in the way of that - do you have any reason to believe that? I mean, Lobster has classes, or at least something that it calls classes: https://aardappel.github.io/lobster/language_reference.html#user-defined-types https://aardappel.github.io/lobster/language_reference.html#...
- ar-nelson 6y agoTake Java as an example. In Java, there are no free functions. Every method belongs to an object or a class. So you couldn't write `f(a, b, c)` as `a.f(b, c)`, because `f` as a free function couldn't exist to begin with. Either it would already be `a.f`, or `f` would be a method of the current class or a static method imported via `import static`, in which case using the `a.f` syntax could deceive readers about what class `f` is a member of. That's what I'm going for with this language, for uniformity and discoverability. If you want to add a new method that takes type `A` as its first argument, you should add it as an extension method on type `A`.
- vanderZwan 6y agoCould you elaborate on what "discoverability" means to you, because don't see any reason in this explanation why an IDE would not be able do autocomplete on `a.f(b, c)`, with automatic documentation on top, which is all that is needed for discoverability in my book. (also, to be clear, I'm not the one who downvoted you)
- tekknolagi 6y agoThis is called unified function call syntax
- vanderZwan 6y agoYou know, now that you mention it, I think every time I mention this feature of Lobster someone explains this to me, and for some weird reason I keep forgetting. Thanks for enlightening me again, hopefully it'll stick this time!
- klibertp 6y agoNim also has this. You can also leave out the parens from calls, which adds to the syntax flexibility.
- Snarwin 6y agoIn D, this is called "uniform function call syntax." [1] It's really handy, not just for OOP but also for pipeline-style functional programming, since it lets you compose functions from left to right. [1] https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...
- thesuperbigfrog 6y agoAda supports that syntax for tagged types: https://learn.adacore.com/courses/intro-to-ada/chapters/object_oriented_programming.html#dot-notation https://learn.adacore.com/courses/intro-to-ada/chapters/obje...
- jayd16 6y agoWould be kind of neat if the language supported returning tuples or anonymous types. ie x(a,b,c) is equivalent to {a,b}.x(c)