  | 
  | 
 
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: clipka 
Subject: Syntax extension: Passing multiple values out of a macro 
Date: 28 Feb 2015 20:51:35 
Message: <54f270a7$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
I've just implemented a syntax extension that you might like: As of the 
newest development version, you'll now be able to assign multiple 
variables with a single #declare (or #local) statement, like so:
   #declare (A,B,C) = (X,Y,Z);
Obviously, this now allows for a single macro to return multiple items, 
like this:
   #macro WindowFrameAndCutout(Pos,H,W)
     #local Frame  = union {...};
     #local Cutout = box {...};
     (Frame,Cutout,Area)
   #end
   #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
How's that? :D
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: Thomas de Groot 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  1 Mar 2015 03:27:23 
Message: <54f2cd6b$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 1-3-2015 2:51, clipka wrote:
> I've just implemented a syntax extension that you might like: As of the
> newest development version, you'll now be able to assign multiple
> variables with a single #declare (or #local) statement, like so:
>
>    #declare (A,B,C) = (X,Y,Z);
>
> Obviously, this now allows for a single macro to return multiple items,
> like this:
>
>    #macro WindowFrameAndCutout(Pos,H,W)
>      #local Frame  = union {...};
>      #local Cutout = box {...};
>      (Frame,Cutout,Area)
>    #end
>
>    #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
>
> How's that? :D
Probably neat, but I confess I do not really understand the example and 
what it does...
-- 
Thomas
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: Warp 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  1 Mar 2015 03:30:04 
Message: <54f2ce0c@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
clipka <ano### [at] anonymous org> wrote:
>    #macro WindowFrameAndCutout(Pos,H,W)
>      #local Frame  = union {...};
>      #local Cutout = box {...};
>      (Frame,Cutout,Area)
>    #end
>    #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
You are returning three values and assigning them into two identifiers?
-- 
                                                          - Warp
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: clipka 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  1 Mar 2015 13:05:25 
Message: <54f354e5$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Am 01.03.2015 um 09:30 schrieb Warp:
> clipka <ano### [at] anonymous org> wrote:
>>     #macro WindowFrameAndCutout(Pos,H,W)
>>       #local Frame  = union {...};
>>       #local Cutout = box {...};
>>       (Frame,Cutout,Area)
>>     #end
>
>>     #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
>
> You are returning three values and assigning them into two identifiers?
Whoops :) - that should have been:
     #declare (MyFrame,MyCutout,MyArea) = WindowFrameAndCutout(...);
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: clipka 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  1 Mar 2015 13:12:38 
Message: <54f35696@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Am 01.03.2015 um 09:27 schrieb Thomas de Groot:
> On 1-3-2015 2:51, clipka wrote:
>> I've just implemented a syntax extension that you might like: As of the
>> newest development version, you'll now be able to assign multiple
>> variables with a single #declare (or #local) statement, like so:
>>
>>    #declare (A,B,C) = (X,Y,Z);
>>
>> Obviously, this now allows for a single macro to return multiple items,
>> like this:
Sorry, forgot some part of the code (I guess I was a bit tired):
>>
>>    #macro WindowFrameAndCutout(Pos,H,W)
>>      #local Frame  = union {...};
>>      #local Cutout = box {...};
         #local Area   = H*W;
>>      (Frame,Cutout,Area)
>>    #end
>>
>>    #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
       #declare (MyFrame,MyCutout,MyArea) = ...
>>
>> How's that? :D
>
> Probably neat, but I confess I do not really understand the example and
> what it does...
Suppose you have a set of macros to generate architecture; in such a 
framework, for windows you'll want both the windows itself, as well as a 
shape to cut a matching hole into the wall. And for some reason you 
might also be interested in knowing the area of the window, though I 
confess I just put it in there just to demonstrate that you can return 
values of different types.
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
clipka <ano### [at] anonymous org> wrote:
> Am 01.03.2015 um 09:27 schrieb Thomas de Groot:
> > On 1-3-2015 2:51, clipka wrote:
> >> I've just implemented a syntax extension that you might like: As of the
> >> newest development version, you'll now be able to assign multiple
> >> variables with a single #declare (or #local) statement, like so:
> >>
> >>    #declare (A,B,C) = (X,Y,Z);
> >>
> >> Obviously, this now allows for a single macro to return multiple items,
> >> like this:
>
> Sorry, forgot some part of the code (I guess I was a bit tired):
>
> >>
> >>    #macro WindowFrameAndCutout(Pos,H,W)
> >>      #local Frame  = union {...};
> >>      #local Cutout = box {...};
>          #local Area   = H*W;
> >>      (Frame,Cutout,Area)
> >>    #end
> >>
> >>    #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
>        #declare (MyFrame,MyCutout,MyArea) = ...
> >>
> >> How's that? :D
> >
> > Probably neat, but I confess I do not really understand the example and
> > what it does...
>
> Suppose you have a set of macros to generate architecture; in such a
> framework, for windows you'll want both the windows itself, as well as a
> shape to cut a matching hole into the wall. And for some reason you
> might also be interested in knowing the area of the window, though I
> confess I just put it in there just to demonstrate that you can return
> values of different types.
I like it. It looks like some Python feature was it an inspiration?
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: clipka 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  2 Mar 2015 10:12:42 
Message: <54f47dea$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Am 02.03.2015 um 15:49 schrieb Mr:
> I like it. It looks like some Python feature was it an inspiration?
No, just general tuple-ish syntax.
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: Thomas de Groot 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date:  3 Mar 2015 03:07:22 
Message: <54f56bba$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
On 1-3-2015 19:12, clipka wrote:
> Suppose you have a set of macros to generate architecture; in such a
> framework, for windows you'll want both the windows itself, as well as a
> shape to cut a matching hole into the wall. And for some reason you
> might also be interested in knowing the area of the window, though I
> confess I just put it in there just to demonstrate that you can return
> values of different types.
>
Yes, I understand the principle but - as is always the case with my slow 
brain - I shall need to play with it in order to fully understand the 
potentials :-)
-- 
Thomas
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
clipka <ano### [at] anonymous org> wrote:
> I've just implemented a syntax extension that you might like: As of the
> newest development version, you'll now be able to assign multiple
> variables with a single #declare (or #local) statement, like so:
>
>    #declare (A,B,C) = (X,Y,Z);
>
> Obviously, this now allows for a single macro to return multiple items,
> like this:
>
>    #macro WindowFrameAndCutout(Pos,H,W)
>      #local Frame  = union {...};
>      #local Cutout = box {...};
>      (Frame,Cutout,Area)
>    #end
>
>    #declare (MyFrame,MyCutout) = WindowFrameAndCutout(...);
>
> How's that? :D
That's great !
=)
I really hope that it also works with functions, arrays, transforms, vectors,
cameras, light sources, materials etc. I.e. everything that be stored in a
variable.
--
Tor Olav
http://subcube.com
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
From: clipka 
Subject: Re: Syntax extension: Passing multiple values out of a macro 
Date: 16 Mar 2015 00:31:20 
Message: <55065c98$1@news.povray.org> 
 | 
 
 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
Am 16.03.2015 um 04:55 schrieb Tor Olav Kristensen:
> I really hope that it also works with functions, arrays, transforms, vectors,
> cameras, light sources, materials etc. I.e. everything that be stored in a
> variable.
I wouldn't dare to raise my head with this otherwise :) (I haven't 
tested most of them, but the implementation is simple enough to be 
confident about it.)
 
 Post a reply to this message 
 | 
  | 
 
 |   |  
 |   |  
 | 
  | 
 | 
  | 
 
 |   |  
 
 | 
  |