|
![](/i/fill.gif) |
Fa3ien wrote in message <4707ba6b$1@news.povray.org>:
> With built-in functions, i can write :
> light_source {... area_light ... circular orient adaptive 2}
> or, as well
> light_source {... area_light ... adaptive 2 orient circular}
>
> I know that almost no programming language allows that kind
> of parsing feature in user-defined functions, but I regret it.
If you do not mind naming all the parameters, a lot of languages can do
that.
Objective Caml can do something like that:
light_source ... ~area_light:true ~shape:`Circular ~adaptative:2 ()
Python has a similar feature, I think.
Perl can emulate that very well using hashes:
light_source ... area_light => 1, shape => "circular", adaptative => 2;
And in fact, almost any language that supports variable number of arguments
can emulate it. For example in C:
light_source(..., "area_light", "circular", "orient", "adaptative", 2, NULL);
This requires a little bit more work inside the user-defined function, but
not much, and some of it can be eased by common helper functions.
Some libraries, like Gtk+, use similar schemes.
Post a reply to this message
|
![](/i/fill.gif) |