1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Better prelude.

This commit is contained in:
Patrick Thomson 2019-10-23 15:10:54 -04:00
parent edd83d466f
commit fde167a236

View File

@ -3,18 +3,20 @@
#record { __name: name, __super: super, __slots: slots };
instance <- \class -> \prim -> \slots ->
#record { __class: class, __prim: prim, __slots: slots };
#record { __super: class, __prim: prim, __slots: slots };
-- object's superclass is type itself
object <- type "object" type #record{};
str <- type "str" object #record { };
str.__new__ = (\contents -> instance str contents #record{});
#record { type: type, object: object, str: str }
getitem <- rec getitem = \item -> \attr ->
getitem <- \super -> \item -> \attr ->
if item.slots.?attr then item.slots.attr else #unit;
#record { type: type, object: object, getitem: getitem }
new <- \class -> class.__new__;
example <- new str "hello";
#record { type: type, object: object, str: str, getitem: getitem, new: new, example: example }
}