POV-Ray : Newsgroups : povray.general : Attempt to POV4 Syntax basics : Re: Attempt to POV4 Syntax basics Server Time
31 Jul 2024 12:26:46 EDT (-0400)
  Re: Attempt to POV4 Syntax basics  
From: Nicolas George
Date: 7 Oct 2007 04:09:53
Message: <47089451@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.