]> ocean-lang.org Git - ocean-D/blobdiff - Ocean-introspection
devel - working on twod
[ocean-D] / Ocean-introspection
diff --git a/Ocean-introspection b/Ocean-introspection
new file mode 100644 (file)
index 0000000..b809622
--- /dev/null
@@ -0,0 +1,59 @@
+Here I collect thoughts about introspection.
+
+
+Introspection can be at compile-time as well as runtime, and can have
+quite a different role.
+In edlib/python I use the documentation string of class methods to
+indicate what 'key' they respond to.  I cannot easily do that in C,
+but could if I have compile-time introspection.  I could do it
+with a sed script that extracts an include file ...
+
+The language would need to allow for extra stuff to be parsed into
+an AST, then the introspection code would run over that AST before
+it was further analysed.  This a bit like gcc pluggins, but
+is writting if the language being compiled, and compiled like
+any other code.
+
+This would be part of a larger feature that any code could run at
+compile time instead of later.  Constant-folding is already a common
+practice and is an example of this.
+
+I would need a simple and stable AST ADT to be manipulated.  Most uses
+would be relatively simple, like collection functions into an array,
+or pre-parsing some internal data structure, possibly sorting it.
+
+It could be as simple as allowing strings in lots of places, and 
+expecting the introspection to parse them - along with various object
+names - and do stuff.
+
+
+Separately there is runtime introspection.
+This would be needed to handle anything not known at compile time.
+
+Mostly this is probably underspecified type.  An 'sprintf'
+type function to be introspected and transformed at compile time
+providing the types of everything could be determined.  And if the
+type isn't known... recording introspection info is probably not easier
+that recording the appropriate dispatch function.
+
+Then there is link-time information.  Compile-time introspection needs
+to all be run at compile-time.  If I load a foreign module at run time
+(or link time), it cannot ask questions that weren't already asked.
+
+Maybe a "standard" compile-time introspector could encode any info
+needed for link-time or runtime introspectors.
+
+
+Introspection could be used for:
+
+ - preparsing data structures
+       e.g. sorting, adding links, ..
+ - annotating for run-time 
+       e.g. storing table of function, with names
+       providing serialization, de-serialization
+ - providing default values for missing args
+ - transforming n-ary args to arrays
+ - adding appropriate dispatch info when passing args to
+      a function that expects objects
+ - adding coverage tracking
+ - adding performance tracking