In Thoughts on a New Language I said:

This relates to the whole concept of the "dictionary created by executing a block of statements". I find this notion of a "block of statements" being a first-class object appealing. Imagine a function that, instead of having a return value, simply returns its bound local variables. I guess Python modules are pretty much that. But I'm thinking of the notion within a file.

There are actually three places where Python uses a block of statements to populate a namespace:

modules

function bodies

class definitions

But imagine that it was a first class object. I'm not really thinking about syntax yet, but one could imagine

{ x = 5 y = x + 2 }

or

block: x = 5 y = x + 2

as possibilities for anonymous blocks. To bind the block to a particular variable, we could therefore say:

foo = { x = 5 y = x + 2 }

or

block foo: x = 5 y = x + 2

Now, what if following on from the previous post and ideas from prototype-based languages like Self, Javascript and Lua you could specify a parent to be traversed in case the block didn't have the requested value. Would there be special syntax for specifying the parent or would it just be a value in the block like __parent__ ?

foo = { __parent__ = bar y = x + 2 }

or

block foo(bar): y = x + 2

In either case, would the evaluation of y be lazy or not?

What about multiple inheritance, which isn't commonly found in prototype-based languages?

Also, would we want to have the notion of parameterized blocks? With the free variable explicit:

foo(x) = { y = x + 2 }

or implicit:

foo = { y = x + 2 }

?

And would you then want to be able to bind that free variable at a later date:

foo % { x = 5 } assert foo.y == 7

(just to arbitrarily pick % to use as the operator symbol)

Also, taking a cue from an offhand remark in Steve Yegge's Universal Design Pattern post about this sort of stuff ( HT: Jonathan Hartley) imagine you have a monster objects like

orc = { hp = 10 } warg = { hp = 5 }

and you wanted to capture the notion that a boss monster has 2 times the hit points of a normal monster of that prototype. Would you use inheritance without binding the __parent__ yet:

boss = { hp = 2 * __parent__.hp }

and later:

orc_boss = boss % { __parent__ = orc }

?

Could we use boss(orc) as equivalent to boss % { __parent__ = orc } ?

Some interesting possibility here, just playing around with the notion of a block as first class object with inheritance and parameterization.

And another crazy though: could this language have something akin to list comprehensions but for these blocks so you could compactly define them programmatically where appropriate? This is a contrived example, but Imagine you have a list of strings and you want to create a block that uses those strings as variable names, all set to an initial value of 1.

That is, you want to get

{ foo = 1 bar = 1 baz = 1 }

from var_list = ["foo", "bar", "baz"]

The main challenge seems to be just coming up with syntax for turning strings into variable names. But imagine (just for the sake of example) that ~x meant the variable whose name is the value of x . Then you could (possibly) do something like:

{ ~x = 1 for x in var_list }

This is all just thinking aloud :-)