mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Better prelude.
This commit is contained in:
parent
edd83d466f
commit
fde167a236
@ -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 }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user