POV-Ray : Newsgroups : povray.beta-test : function declaration and namespace Server Time
30 Jul 2024 08:20:43 EDT (-0400)
  function declaration and namespace (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From:
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 07:27:35
Message: <sj4j3ucmp9do8nlr46a56cf09bu95jrh6m@4ax.com>
On Mon, 07 Jan 2002 13:15:30 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:
> > below script stops at header of macro with message
> > "Expected 'identifier or expression.', function_id found instead"
> >
> > #local F=function{x}
> > #macro P(F) #end
>
> Works as it should.  Please refer to the documentation.

6.2.8.1: "PARAM_IDENTs are a list of zero or more formal parameter identifiers
separated by commas and enclosed by parentheses".

F is formal in local namespace of macro P for me and should works just like
below script:

#local F=function{x}
#macro P(C) #local F=C; #end
P(1)

Is there any other place in documentation where it is precised ?

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 07:32:20
Message: <3c399554@news.povray.org>

Skiba <abx### [at] babilonorg>  wrote:

> 6.2.8.1: "PARAM_IDENTs are a list of zero or more formal parameter identifiers
> separated by commas and enclosed by parentheses".
>
> F is formal in local namespace of macro P for me and should works just like
> below script:
>
> #local F=function{x}
> #macro P(C) #local F=C; #end
> P(1)
>
> Is there any other place in documentation where it is precised ?

6.1.6.1 Functions and Macros


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From:
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 07:35:24
Message: <4d5j3ukkckm30bsj12n0i72i04uhgmmkrt@4ax.com>
On Mon, 07 Jan 2002 13:32:17 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:
> > Is there any other place in documentation where it is precised ?
>
> 6.1.6.1 Functions and Macros

but it is about calling macro,
I'm talking about declaring

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 07:39:55
Message: <3c39971b$1@news.povray.org>

Skiba <abx### [at] babilonorg>  wrote:

> but it is about calling macro,
> I'm talking about declaring

???

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From:
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 07:47:47
Message: <ps5j3u42jdj85v0jfr3jeaj8e2i2vn3qsa@4ax.com>
On Mon, 07 Jan 2002 13:39:55 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:

> ???

here is list of cases from 6.1.6.1.

"You can use macros in functions, but the macros will be called only once when
the function is defined, not every time the function is called."

This is not my case becouse I'm not declaring function.

"You cannot pass function variables to the macros."

This is not my case becouse I'm not calling macro and therefore no parameters
are passed.

"You can pass functions to macros, how to do this is best explained by an
example."

As above.

I'm declaring.

This is parsed ok:

#macro P(F) #end
#local F=function{x}

and this not:

#local F=function{x}
#macro P(F) #end

The only difference is the order of lines.

ABX


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 08:18:10
Message: <3c39a012@news.povray.org>

Skiba <abx### [at] babilonorg>  wrote:

> This is parsed ok:
>
> #macro P(F) #end
> #local F=function{x}
>
> and this not:
>
> #local F=function{x}
> #macro P(F) #end

Ah, now I see.  I missed that it wasn't a macro call.  I am not sure what it
is then.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From:
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 08:20:29
Message: <c28j3uod9ldtp8bo2cf8fq1t5p9ugdddq1@4ax.com>
On Mon, 07 Jan 2002 14:18:08 +0100, "Thorsten Froehlich" <tho### [at] trfde>
wrote:
> Ah, now I see.  I missed that it wasn't a macro call.

Now I'm happy it's not my English again :-)

ABX


Post a reply to this message

From: Gleb
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 09:23:57
Message: <3c39af7d@news.povray.org>
The difference is not only the order of lines, but in the last case "F" in
known as function name

in current block, so POV is correct, reporting an error..

If we put " #local F=" inside e.g. a macro block, like below, it works OK

//----------------------------
 #macro  M(F)
 #local F=function{x}
 #end

 #macro P(F) #end

 /*----------------------------
 6.2.2.2  #declare vs. #local

 Use of #local in the main scene file (not in an include file and not in a
macro)
  is identical to #declare.
  For clarity sake you should not use #local in a main file except in a
macro.
 */


atb,

gleb


"W?odzimierz ABX Skiba" <abx### [at] babilonorg> wrote in message
news:ps5j3u42jdj85v0jfr3jeaj8e2i2vn3qsa@4ax.com...
> On Mon, 07 Jan 2002 13:39:55 +0100, "Thorsten Froehlich" <tho### [at] trfde>
> This is parsed ok:
>
> #macro P(F) #end
> #local F=function{x}
>
> and this not:
>
> #local F=function{x}
> #macro P(F) #end
>
> The only difference is the order of lines.
>
> ABX


Post a reply to this message

From:
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 09:35:13
Message: <a6cj3u06t5j5piqv2pgb1a4ge34bfd3qcj@4ax.com>
On Mon, 7 Jan 2002 14:23:57 -0000, "Gleb" <gk1### [at] sotonacuk> wrote:
> The difference is not only the order of lines, but in the last case "F" in
> known as function name

I know, I pointed order to underline what changed.

> in current block, so POV is correct, reporting an error..

not for me

F listed in declaration of macro is valid name _only_ in local namespace of this
macro so according to "redeclaration of functions is not allowed" it is formal
as long as it will not be declared as function.

> If we put " #local F=" inside e.g. a macro block, like below, it works OK

yes, I pointed it in this thread

ABX


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: function declaration and namespace
Date: 7 Jan 2002 19:05:07
Message: <3C3A373B.2AB132D2@hotmail.com>
Thorsten Froehlich wrote:
> 

> Skiba <abx### [at] babilonorg>  wrote:
> 
> > This is parsed ok:
> >
> > #macro P(F) #end
> > #local F=function{x}
> >
> > and this not:
> >
> > #local F=function{x}
> > #macro P(F) #end
> 
> Ah, now I see.  I missed that it wasn't a macro call.  I am not sure what it
> is then.

It is just one function declaration and one
macro declaration.

- And the macro's parameter just happens to
have the same name as the function.

I think it should be valid code to write. 

Just as this is allowed:

#declare S = sphere { <0, 0, 0>, 1 }

#macro AnyMacro(S)
  (2*S)
#end // AnyMacro

#declare A = AnyMacro(4);


Tor Olav


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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