-
Notifications
You must be signed in to change notification settings - Fork 7
Use (A×B×C) names for TypedTuples #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: deduction
Are you sure you want to change the base?
Conversation
This commit adds a new class for creating (anonymous) typed tuples. On an implementation level it leverages Pharo's slots to define tuple elements and their types. As of now, only rudimentary support for creating tuple types and instantiating them is added. Nice APIs may be (will be) added as needed.
This is the code written in the our programming session.
Smalltalk-25 is, (to borrow Luciano's words) about "reimagining Smalltalk categorically". Tuples are meant to be the "product" half of the cartesian structure on data. (A×B×C) is the natural notation everyone expects for product types. It also nicely renders void as (). The downside is that in the current syntax we lose homoiconicity. Two comments on this: 1. I am not sure if Smalltalk-25 wants to be more like Lisp, or like Haskell. 2. Maybe the blame is on the current syntax that () doesn't evaluate to void?
janvrany
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is:
t1 := Int ⨰ String,
t2 := Compiler evaluate: t1 name.
Should t2 by the "same" tuple, that is Int ⨰ String?
If so, the code breaks for tuples where ivars (slots / elements) are named, for example:
TypedTuple ofAll: { #x -> Int . #y -> Int } (this was the idea behind my original name).
I do not know whether or not we want that.
Other than this comment LGTM.
That's "the Lisp perspective" I mentioned in the commit message. The class name design of Smalltalk-80 follows along very nicely, in that the homoiconicity equation: holds for classes because the class's name evaluates to the class. The bigger question is, whether we accept this principle, or do we accept the arguments of the Haskell designers against homoiconicity, and consciously reject
is exactly what I am referring to when I say "The downside is..."
If we follow the Lisp perspective, then yes. But if we follow the Haskell perspective, |
but, with this new ∷ (*) we can elegantly solve this, preserving homoiconicity for "tuple classes" just like ST80 does for normal classes. So, I'm deferring merge of this until ∷ gets in and then update this PR. (*) discussed privately |
|
Hmm. So now the difference between Named Records (i.e. |
Yeah, I was thinking the same. Let's slow down a bit and let me think. |
33a9885 to
420f208
Compare
Smalltalk-25 is, (to borrow Luciano's words) about "reimagining Smalltalk categorically". Tuples are meant to be the "product" half of the cartesian structure on data. (A×B×C) is the natural notation everyone expects for product types. It also nicely renders void as ().
The downside is that in the current syntax we lose homoiconicity. Two comments on this: