]> ocean-lang.org Git - ocean-D/blobdiff - Ocean-types
updates
[ocean-D] / Ocean-types
index f0f9d929494acf7ae114e17776f33d09710154cb..b29b64c2729192aac89af8a010d8cf502e3b1f64 100644 (file)
@@ -94,9 +94,43 @@ Plan:
      I think I need to disassociate the type from the storage.
      So a 'value' is a parsed constant, but something new is needed for
      the content of a variable.
+     Also, something new is needed for an intermediate lvalue such as an
+     index to an array or a field in a record.  Ths is a type plus a pointer.
+     What about rvalues and the result of a calculation.  I guess I store
+     that in a temp location, with a pointer...
+
+     I need to be clear what "interp_exec()" returns.  Conceptually it
+     can be an object of any type, and for procedures it can be a tuple of
+     objects.  It needs to identify a type and a value of that type.
+     The "value" might be a reference into a variable, or it might be
+     a copy from a calculation.  Eventually the reference will have
+     ownership information
   const
   struct
 
+
+Steps:
+ 0/ when does 1/2 produce an integer?  Only when explicitly expected.
+ 1/ remove 'tail' from value
+ 2/ define a 'type'.
+ 3/ Add a 'Vtyped' vtype and a 'type' pointer
+ 4/ add an owership enum: borrowed, single
+ 3/ add a 'void *valref' ??
+ 4/ Convert num bool str label to Vtyped
+
+No, this is awkward because propagate_types wants a 'type' and this intermediate
+format has a enum+pointer.  So make it just a pointer...
+What do I do with
+  Vnolabel - rule flag
+  Vunknown   - NULL pointer
+  Vnone  - special value
+
+
+ A 'type' must be able to:
+  check is it can convert to some other type, reporting if it wants to
+  convert to another type.  This requires visibility into other types.
+  print, compare, parse
+  add subtract multiply divide index
 ----------
 
  I currently have an enum of types that is used to test compatability
@@ -142,3 +176,48 @@ Plan:
 
  allocating isn't really a top priority, so I should just focus on
  non-allocated types.
+
+
+-----
+I need a list of steps again:
+
+ - look up type by name and add syntax for
+      name : type = value
+   and
+      name : type
+
+ - Add arrays:
+      name : type[size]
+    declares an array of that type/size
+      name : [] = [ 1,2,3 ]
+    declares an array of 3 numbers.
+      name[1]
+    extracts an element from the array,
+      name[2] = 4
+    updates an element
+      name[4:5]
+    creates a slice, which can be stored in a var (borrowed ref) or
+    assigned to
+
+    This requires:
+     - new type class which has a size and member type
+     - new type access methods: index and size(?)
+     - new syntax
+     - new manifest values: [a,b,c] creates an array of whatever member type.
+
+ - add syntax for
+      struct name : [[ name : type ]]
+   to define a new struct
+
+ - add syntax to extra a field from a struct
+        how is this type-checked if I don't know the type yet?
+
+ - add syntax for pointers
+     a:= new(struct foo)
+     a:struct foo^ = new()
+
+-------
+Questions:
+  If I declare "struct foo ..." do I use "foo" or "struct foo" to ref the type?
+  I think just "foo".
+  So structs, records, enums, and classes must have distinct names.