Example Showing Difference Between 'record' and 'table' #477
Replies: 3 comments 4 replies
-
In theory the record version should also allow non-primitive API parameters. Can you give an example of something that did not work? Maybe it's something that the current documentation isn't explaning very well... |
Beta Was this translation helpful? Give feedback.
-
Inside the compiler we call those "primitive types" and "garbage collected types" ("gc types"). However, I'm not sure if this is a distinction we need to bring attention in the documentation... Pallene doesn't treat primitive types differently than gc types.
Are you referring to recursive types? Those aren't implemented yet, but we want to add them in the near future.
I think the more common convention for gradually typed languages is to put the "any" on a separate category by itself. But I'm not sure if there's a common name for it. Perhaps because there is less of a desire to name the category, because there is only one item inside it. |
Beta Was this translation helpful? Give feedback.
-
I would like to keep using "primitive" with the meaning we use inside the compiler (for "not garbage collected types"). It also happens to be the same meaning from Java. Maybe we could have a different name for what you're calling primitive. What about "basic types"? String would be a basic type (its type constructor has no type arguments) but it would not be a primitive type (it is garbage collected, and stored on the heap). |
Beta Was this translation helpful? Give feedback.
-
Folks new to Pallene may find this example useful. It helped me get clear on the use of the two concepts 'record' and 'table'.
It has two modules, both of which define 'Point'. One defines it as a record and the other defines it as a table.
Point1_module.pln
: uses recordPoint2_module.pln
: uses tableThere is a main Lua file that demonstrates the differences in making calls into these modules.
Point_main.lua
: calls both modulesPoint1_module.pln
Point2_module.pln
Point_main.lua
running it...
Beta Was this translation helpful? Give feedback.
All reactions