X-Git-Url: https://ocean-lang.org/code/?p=ocean-D;a=blobdiff_plain;f=Blog-pointers;h=2539232ddae05443b331b93e01e327ac716f7311;hp=372efc66b0ef889252e5f4fd610b9db42dff06ae;hb=fb71b26483853b4e8198c3b5ca1c3f2ec554a800;hpb=45aab75f5351e843430399030c27a13cd7edea2e diff --git a/Blog-pointers b/Blog-pointers index 372efc6..2539232 100644 --- a/Blog-pointers +++ b/Blog-pointers @@ -167,7 +167,7 @@ Rust uses smart pointers to implement others. It even has Box<> to create on heap instead of stack. -Why doesn't I just do that? Partly because I don't have classes yet!! +Why don't I just do that? Partly because I don't have classes yet!! I like a simple syntax to test if a pointer is over-loaded. if pointer? @@ -241,3 +241,30 @@ or better fun foo(a:x, b:x) : x +------------------------ +Years later - March 2021 + +I need somewhere to start so I need to be able to ignore lots of this detail. +So in the first instance all references are counted references. They must refer +to a struct that contains 'refcount'. + +A reference is declared with + name : ref base-type +and the base object can be accessed with + name.ref +though this can sometimes be inferred from "name". +In particular + name.foo +will find 'foo' either as an attribute of name, or of what name refers to. +If name refers to a reference, this recurses. + +A ref can be checked with "name.valid" + +A new object can be allocated with "name.new()", which returns the ref. +So "name.new().valid" is true if the allocation succeeded, which is always +will on Linux. + +Future ideas might include: + type name : ref(attr,list) basetype +where attr,list can include borrow,counted,single, etc +