X-Git-Url: https://ocean-lang.org/code/?p=ocean-D;a=blobdiff_plain;f=Ocean-methods;fp=Ocean-methods;h=8876f5514168a75549537dc62a3a5b654599f967;hp=0000000000000000000000000000000000000000;hb=509e0c8cd5c64e608032aa95a51dd5096185c338;hpb=fb71b26483853b4e8198c3b5ca1c3f2ec554a800 diff --git a/Ocean-methods b/Ocean-methods new file mode 100644 index 0000000..8876f55 --- /dev/null +++ b/Ocean-methods @@ -0,0 +1,35 @@ +Methods in Ocean + +methods are any function that is found from a given value. +It can be associated with the type or the value + +An interface is a set of methods. A concrete type can export an +interface and a formal type can require an interface. + +A value can be combined with a concrete interface to override or augment +what it's type natively has. Value methods are not so easily +overridden. + +The first arg of a method must match the owner, and other args can be of +that type + +Interface names are per module. +Method names are per interface. When a variable supports multiple +interfaces and names don't conflict, interface name can be left out. + +maybe value method use . and type methods use : ?? + that would make "case functionname :" tricky to parse. + + +Thought: + Rather than anon structs, allow struct AND references to be marked as 'follow' + so anything behind the object appears in the parent. + Then foo.method can possible follow a chain of pointers from foo to find the method. + + foo might be an inode and have a pointer to a superblock, which has a + pointer to a methods struture contains 'getattr'. Then 'foo.getattr' + transparently becomes 'foo.super.super_methods.getattr. + + Question. In what circumstances is 'foo' passed as first argument? + Probably it happens by default, but some syntactic escape allows something else + to be passed. Maybe foo::something() ??