VCC now has type-driven properties

Poul-Henning Kamp phk at phk.freebsd.dk
Tue Jun 4 07:16:37 UTC 2019


As you may have spotted in recent commits and notably 2962375b4ed80e,
VCC now has type driven properties.

This means that subexpressions of a given type can express that
property, no matter how we got to it in the first place.

If we defined a type driven property from DURATION called
"foobar" it would be possible to write:

	set beresp.http.qqq = (beresp.ttl + 4m).foobar;

Right now, this has not changed the syntax of VCL, we're still 4.1
because the only use is for the storage.*.* variables for which
the syntax remains the exact same.

If we want to, some of the stuff in vmod_std can now be made
slightly more intutive syntax-wise:

	BACKEND.healthy -> BOOL

	IP.port -> INT

Note that these are *properties* `EXPR.name` they do not take any
VCL arguments beside the expression they work on.  (The C-implementation
can of course take other args, like VRT_CTX)

It would not be too hard to also do *methods* `EXPR.func(args)`,
so that one could also do things like:

	set bereq.http.qqq = beres.ttl.format("%.3f")

But I am not going to implement that until we have more convincing
use cases than that.

A bit more work would be to allow vmods to implement type driven
properties and methods, but again:  Convincing use cases ?.

Proposals and ideas are welcome.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


More information about the varnish-dev mailing list