by jcupitt · 4y ago · 0 comments
You can't have circular references to the top level, but you can do recursive definitions within a cell, which is maybe spreadsheety too.
You can use scraps of code to set the GUI behaviour, which is a bit crazy. Try making a region on an image (open an image view window, hold down CTRL, drag down and right).
Back in the main window, press the down button to the left of to the label of the cell containing the region and you'll find you can open it up. Keep clicking and a lot of rows will appear -- including left, top, width, height, etc. If you drag the region around and resize it, you'll see all these numbers update.
Click on the number for height and you can edit it. Enter "width * 2" and try resizing the region.
I don't like plug-and-socket style graphical node graph interfaces personally -- I think they are hard to reason about, and things like composition and rewriting feel unnatural (to me). I came out of the functional programming community and I wanted things like referential transparency.
nip2 is supposed to be a graphical interface that's an expression of a set of relations. It has a three part model:
1. You enter scraps of code (or pick menu items) to build an object in nip2's programming language.
2. nip2 looks at the constructed object and draws the GUI.
3. Changes to the GUI trigger "edit" functions on the constructed object to update it.
4. ... if you go back and edit the code that originally constructed the object, the GUI resets.
So your code and the GUI independently update the constructed object, with code taking priority. You get a stateful GUI with a purely functional programming language and you get to keep equational reasoning.