[LV2] Thoughts on a clearer atom forge API

David Robillard d at drobilla.net
Sun Jan 12 16:10:34 PST 2014


On Sun, 2014-01-12 at 23:49 +0000, Harry van Haaren wrote:
> On Sun, Jan 12, 2014 at 11:25 PM, David Robillard <d at drobilla.net> wrote:
> 
> > That's my best proposal so far.  Do better.
> >
> 
> I'll put this up for discussion: how about an OSC type interface?
> 
> []
> >     a my:Message ;
> >     rdfs:label "A wild message appears!" ;
> >     my:intensity 9000 .
> >
> 
> In order to create above message,
> // si representing one "string" and one "int" => "si".
> message = forge_create( "si", uris.rdfs_label,  "a wild message appears!",
> uris.my_intensity, 9000 ); ?

Hm.  I never considered varargs.  This would *maybe* be possible, in C++
only, with either a lot of ugly template hackery or C++11 varargs
templates, since it requires varargs + strong typing.  Alternatively you
could add a type URI parameter for every value and do it C style.  Very
bad things would happen if the exact required types weren't passed, but
this is par for the course for C varargs anyway (though compilers are
clever enough to type check printf like functions, here you'd have no
help at all).

However, a more fundamental problem is that I don't think it could work
for nested containers, since the child parameter would be evaluated
before the parent, and thus be appended before the parent.

It might be nice to include container-specific varargs wrappers like
this for making simple objects, but I don't think such an interface can
do it all.  So, I'd still like to make the underlying full-power
interface as clear as possible.

-- 
dr





More information about the Devel mailing list