VBScript guarantees that the GC will run after every line, so if you create an object and don't keep a reference, its destructor will be called at the end of the line. This allows you to do a number of interesting things, one of which is simulating optional arguments:
with foo(mandatoryArg)
.optArg = 42
end
Another is allowing for a convenient builder syntax:
with Schema.define("Foo")
.attr "name", String
with .attr "key", String
.lengthEquals(10)
end
end
In this example, define and attr return objects that finalize the schema and attribute definitions in the destructor.
I've been calling the temporary object an ephemeron, but I was wondering if there was a preexisting term for such constructions. Anyone seen this elsewhere?