]> ocean-lang.org Git - ocean-D/commitdiff
updates
authorNeilBrown <neil@brown.name>
Fri, 26 Nov 2021 11:16:30 +0000 (22:16 +1100)
committerNeilBrown <neil@brown.name>
Fri, 26 Nov 2021 11:18:25 +0000 (22:18 +1100)
00-TODO
Ocean-types

diff --git a/00-TODO b/00-TODO
index eafc4eec4ee1e890d3ffa76b96bc377e707bdc1f..56d26e39cb03bff4a43ccfb498fccc08b1a5c3f3 100644 (file)
--- a/00-TODO
+++ b/00-TODO
-This is a living document - delete things when done.  Avoid discussion.
+This is a living document - delete things when done.  Avoid discussion.
 
-Current version (Cataract Creek)
-- _interp_exec() to accept a value*, and type, and only copy large value there.
-- functions to return struct with name assignment - bare 'use'?
-    struct is open-coded in header.  Later a similar effect
-    could be achieved with a named struct marked 'transparent'
+## Needs implementations
+
+### Current version (Cataract Creek)
+
+- allow global names to be used before they are declared.  Assume global
+   if undeclared, and complain in final analysis.
+- allow type names to be used before declared.  Need to re-evaluate all
+  type sizes after parse.
+- resolve the HACK of allowing assign from struct when name starts space.
 - '?' prefix operator returns Boolean, index operator for strings. Can be used to
    test for end-of-string
 - ?? infix operator return LHS if '?' on it would succeed, else RHS
-- reference to struct (@foo), with @new, @free, @nil and ? to test
+- reference to struct or intrinsic (@foo), with @new, @free, @nil and ? to test
+- add [] as size-of-array
+- replace [foo::] declaration of array with [] - fix all main() calls
 
-Next Version (Govetts Cree)
-- int nat cyc {i,n,c}{8,16,32,64}
-- # & | ~ &~  - no shift: use (N * #shift) or (N / #shift)
+### Next Version (Govetts Creek)
+- int nat cyc {i,n,c}{8,16,32,64} - maybe not cyc - it needs size.
+- ops: # & | ~ &~  - no shift: use (N * #shift) or (N / #shift)
 - op=
 - enum, with multi-valued names.  enum foo { yes, no, many(10) }
   bar:foo=.yes; if bar == .no... if ?bar.many: print bar.many, "items"
+  Maybe .true and .false for Boolean
 - set, with bool or int members.  set foo { pinned, memalloc, priority(4) }
   bar:foo = .memalloc | .priority(2). if bar.pinned: bar.priority += 1
+. array slices - references to arrays
+- array access to read bytes from strings.  How to get length?  "?string[4]" ??
+        array[] gets length??
 
-Subsequent version
+### Subsequent version
+- 'return' statement similar to 'use', but only valid a function context
+- 'return' can take no value when function has inline/transparent return value
 - simple methods.  Define "func type.name...." and the name will only be visible
   within namespace for type.
-- array access to read bytes from strings.  How to get length?  "?string[4]" ??
 - optional args for functions - if value given
 - named args?  Needs to look like manifest structs
-- array args - last parameter can collect all remaining as array.
-
-And then
+- array args - last parameter can collect all remaining as array if attribute 'open'
+   do I need attribute?  Can anything be type compatible with both X and []X ??
+- initial values for return parameters
+- convert between string and array-of-cyc8
 - float64 float32
-- enum as array index.  foo:[:enum]int.  foo[.baz] = 23
-
-Later
-- string manipulation
-- structs
-   - const fields ... what does that mean?  Assign once as initialization?
-      Can be used for array size? What else?
-      'const' is wrong word.
-      I want 'const' for record to be type-wide constants, like enum.  I think
-      These would become read-only.  Maybe "init_only"
-   - anonymous field - array or struct (or pointer to these)
-      multiple anon struct are allowed if they don't conflict
-      no - transparent fields!  They still have a name, but you can
-      look through it.
-   - [] can apply to transparent array field
-   - transparent struct field gets fields interpolated
-
-   - How to give attributes? just say the word?
-       struct foobar:
-               x:content  transparent
-               size:number
+- transparent fields, parameters which are structs or pointers
+- transparent fields which are arrays
+- transparent results from functions to have same effect as inline-results
+- manifest values for records: [.foo = a, .bar = b]
+- manifest values for arrays: [expr = expr, ...]
+- constant structure definitions
+- const structures can inherit from another, and update select fields.
+- 'use' labels *must* appear in case statements.
+- 'then' can extend a case section into some other.
 
+## Needs Design
+- union types - how do I want to support these? inheritance with variance?
+- lambda
+- 'error' value for various types. NIL for pointer NaN for float, extra flag bit
+   for integers.  -MAX_INT ??
+- enum as array index.  foo:[:enum]int.  foo[.baz] = 23
+- init_only fields
+- const fields in structs: like const, but in 'type' namespace, not 'module'
+- 'borrowed' and 'owned' attributes for pointers.  .free method
+- interfaces - list of methods that must be defined
+- standard interfaces to access operations: group, field, binary, logical
+- modules - exported names in versions, and import lists
+      on types, fields, constants, etc
+- foreach variable-list := make_generator() do
+      A generator has 'first', 'next' and 'finally' methods
+      'first' and 'next' return the same type which is conditional ('?' works)
+      'finally' returns some other type - possibly Tnone - which goes to
+      a set of case at end of loop
+
+- attributes for fields and local variables
+    transparent - names inside can be accessed directly
+    
+    handled    - accesses convert to function calls??
+    constant   - compile time constant - not stored
+    stable     - ??
+    add-only   - ?? like append-only.
+    read-only  - set early never changed?
+    mutable
+    owned      - Can be borrowed and freed
+    borrowed   - There is somewhere this is borrowed from
+    dependant  - ???
+    pure       - definitely not an error
+    endian(big,small,pdp)
+  attributes for whole struct
+    unsorted   - fields appear as written
+    packed     - like unsorted, but no gaps permitted.
+
+- lambda functions for passing as arg to function.
+   Are these always there to provide an interface for a value?
+   Do I want a syntax for functions that just provides a value
+     func (a:number; b:string):number = a+b[]
+   
+- units for numbers
+- iso suffixes for number?
 - static variables.  Easy to implement, but need a syntax.  Something
   really loud.
-
-- manifest values for arrays and structs [a,b,c]
-    or [.foo=a, .bar=b] or [ [1]=a, [2]=b]
-   That last doesn't parse easily, unless we require tags... not a good idea.
-   [ .[1] = a, .[2] = b ] ?? Maybe.
-   or () to group, [] for index. To (.foo=a) ( [1] = b )
-
-   I think that last works. () might almost be optional
-     .foo=a
-   is an expression means a structure with a .foo field assined to 'a'
-     [3] = 2
-   is an array of at least 4 elements with 4th set to 2.
-  Or: an expression that starts '[' is a manifest struct or array.
-   It contains ',' separate list of assignments.
-   Each is either ".name = expr" for struct or "expr = expr" for array
-   Except that would prevent array with enum index.  Is that a problem?
-
-
-- pointers
-   - owned or borrowed
-   - pure, loaded, overloaded, augmented
-   - owned: once, counted, collected
-   - shared or thread-local
-- array slice
-- array buffer - can be added to and grows.
-
-- allow "do stuff" as a stand-alone statement (scope)
-- 'use' labels *must* appear in case statements.
-- 'then' can extend a case section into some other.
+- concurrency
+      implicit and explict
+      reference attributes for locks and refcounts etc
+      RCU
+  - do/go/run/fork/async complex statement
+     All local variables accessed in the body are read-only
+     and copied to a new frame, and code is run in a new thread.
+     Thread is mostly invisible.  It interacts through shared objects,
+     particularly the caller might create a channel and the thread
+     might send messages on it.  Any interesting handshakes
+     are mediated by appropriate data structures.
+
+- arbitrary value asserts tied to variable attributes.
+  e.g. ranges for value and relationships between fields
+  These are tested by compiler at any changed.  Somehow.
 
 - expose parse info for editing by code run at compile time.
   This allows new attributes to be implemented in app code.
   E.g. handling bigendian fields by adding conversion functions.
 
-Next version (Govetts Creek):
-- functions and procedures
 - Finalize what a "main" program looks like.
+   should argv come from a library (sys.argv), or should environ go to main?
 
-Much later
-- per-field attributes
-    constant, stable, add-only, read-only, mutable, owned, borrowed, dependant, pure
-- records
-- enum / set
 - classes
    - constructors and destructors - or "after" ??
      destructors, which can be declared inline
    - vtables, fat pointers, list of approaches
-- operators as interface methods
-     + - * / etc make an arith interface add sub mult div
 - interfaces, inheritance
-- modules, imports and exports
-     public(version) on types, fields etc
 - closures, threads, co-routines, generators lamdas
 - generics/templates.  These should be just a compile-time
   decision.  Same code can be called with suitable methods passed, or
@@ -122,15 +142,16 @@ Much later
 - exceptions ??
 - ensure list_head type concept can work
 - "union" type ??
-- pattern matching for destructuring??
-- casts??
-- typeswitch?
-- iso suffixes for number?
-- foreach?
-- break/continue or "next","last" - hopefully 'use' is enough
-- algebraic types
-
-Library functions:
+NO - pattern matching for destructuring??
+- casts to and from "binary".
+NO- typeswitch?
+- ??? algebraic types
+
+## Needed in library
+ - augmented and overloaded pointers
+    An augmented pointer can also store a flag- for a bitlock etc
+    An overloaded pointer can alternately store an int - e.g. error code
+ - garbage collection?
  - UTF8 string disection
  - search, regexp
  - cvt() interface an format() function
@@ -140,4 +161,5 @@ Library functions:
  - sockets
  - http
  - html
- - gtk? xcb?
\ No newline at end of file
+ - gtk? xcb?
+
index ed57f26d1407bee3baa002089d14bec3b85688fb..a89544cc3c87da1b04b679ff0cff88bc5d401720 100644 (file)
@@ -146,7 +146,7 @@ What do I do with
   add subtract multiply divide index
 ----------
 
- I currently have an enum of types that is used to test compatability
+ I currently have an enum of types that is used to test comparability
  and for propagation.
  This needs to change .... I guess I need a struct type* What goes in it?
   - name
@@ -167,6 +167,26 @@ What do I do with
      .Bool.true = a:char; b:char
      .Bool.false = ......
 
+  I like "inheritance" but that doesn't allow the size of the whole to
+  be known in advance.
+  I need a way to talk about which instance is active, even if the value
+  isn't stored.  So Pascal-like variant records are good.
+  Maybe a struct could be declared as 'extensible' and other structs
+  could 'extend', and it literally makes it bigger
+  struct a extensible {x1:int}
+  struct b extends a {y1:int}
+  struct c extends a extensible {y2:int}
+  struct d extends c  {z1:int}
+
+  now 'a' has room for x1, (y2 and z1) or y1
+  Which is used depends on context .. or by assertion on content.
+  So extensions can set values for existing fields
+    struct z extends a {x1=4; string c}
+
+  Syntax is a bit clumsy.  Do I need "extensible"??
+  
+
+
  Are enums just a fancy way of doing 'const'?
  I could have
    const: a=1; b=2; c; d