[Grace-core] Placeholders-initialization of circular data structures

Lex Spoon lex at lexspoon.org
Sun Nov 18 15:15:13 PST 2012


Adding some laziness sounds like a great goal, perhaps something to be
enabled via a dialect.

Also, the component-assembly example that you give is very important
in practical software development. It has led to "dependency
injection" frameworks being developed.

On a design note, one thing to consider is whether you really want
placeholders to be able to flow to positions that aren't marked
specially in any way. In the given example, the arguments to the
"make" methods are not marked as special in any way, but they are
expected to be able to handle a placeholder. As given, this means that
the implementation must be ready for a placeholder to flow to almost
any variable or expression. Since Grace is implemented on other VMs,
rather than having its own custom VM, this requirement could lead to a
slowdown even for code that isn't using placeholders. It might work
better to mark potentially lazy variables as such to make the
implementation much easier.

As a brief report on existing experience, Scala has a "lazy val" that
also gives just a little bit of laziness--even less than placeholders!
To try and be brief, they allow some really elegant formulations,
allowing you to ignore rigid control flow orderings when you don't
really care. However, they happen to be slow in the Scala
implementation (long story), and so most developers appear to avoid
them. It turns out that life without them isn't really so bad; for
example, you can get a similar effect by explicitly passing around
promises.

Lex


More information about the Grace-core mailing list