POV-Ray : Newsgroups : povray.beta-test : Buglist 22 Apr 2002 (RC2) Server Time
29 Jul 2024 22:34:14 EDT (-0400)
  Buglist 22 Apr 2002 (RC2) (Message 31 to 34 of 34)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Coridon Henshaw
Subject: Re: Buglist 22 Apr 2002 (RC2)
Date: 5 May 2002 02:51:37
Message: <Xns92051D18BE4E6csbhccse@204.213.191.226>
John VanSickle <evi### [at] hotmailcom> wrote in news:3CD46365.433CEFA3
@hotmail.com:

>> Parsing fails on line 248 of shapes.inc when the Spheroid macro
>> attempts to use 'Center' as a parameter name.
 
> A consistent naming scheme will alleviate this problem.
> 
> For instance, I prefix vector names with a v, scalars with s,
> index variables with i, and so on.

This is what I'd call putting the cart before the horse.

Given that shapes.inc and the other #macro-laden #includes are a standard 
part of the distribution, I tend to think it'd make far more sense for them 
to use a consistant naming scheme to stay out of the *users* hair rather 
than for the user to go through all kinds of contortions to stay out of the 
#include's hair.

I mean, you wouldn't like the idea of prefixing every name in a C program 
with an underscore (etc) so it wouldn't collide with names used by the C 
RTL, would you?  Of course not.  That's why the component names used by C 
RTL are prefixed with underscores: so the user gets virtually the rest of 
the non-defined namespace to himself/herself.


Post a reply to this message

From: Coridon Henshaw
Subject: Re: Buglist 22 Apr 2002 (RC2)
Date: 5 May 2002 02:57:30
Message: <Xns92051E17F8CBDcsbhccse@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in
news:3cd3a6f6@news.povray.org: 

> It isn't a new limitation in 3.5 also you seem to give that impression.

Try this on 3.1:

#macro Center(Obj)
object {Obj}
#end
#include "shapes.inc"
#declare X = sphere {0,1}
Center (X)

It won't choke.  Now try it on 3.5.  Now try to find anything in the 
documentation that says this code is no longer valid under 3.5.

(Yes, I know /why/ it won't choke 3.1...  The reason why it won't choke 3.1 
is irrelevant; the fact that it *does* choke 3.5 is the problem.)

> Having the same name twice in the same namespace simply cannot work. 

Please tell that to the RC3 binary.  It copes just fine with #declared/
#localed names that match macro parameters:

#local X = function(x,y,z) {x+y+z}
#macro A(X) #end

Given that there's no valid reason to use the output of a macro to 
determine the name of another macro's parameters, not performing macro 
expansion during this portion of parsing seems reasonable for consistancy's 
sake alone.  For instance, why should the code above work when #macro X() 
#end #macro A(X) #end doesn't?

> the documentation explains the namespace rules. 

In this specific case, telling the user that he/she can't do #macro A() 
#macro B(A, D) is rather pointless when the user doesn't know that #macro B
(A, D) exists in the first place.  The point is that the standard includes 
are consuming huge swaths of the namespace without any real documentation  
or regard for what they might be stepping all over.  Finding safe names was 
not a matter of luck with 3.1; it is very much a matter of luck with 3.5 as 
soon as one #includes anything.  I don't think this change is particularly 
rational or user friendly.

Again, if the parser cannot practically be fixed at this stage, could the 
standard includes at least be modified so their macro parameter names are 
all lower case (like all other Pov keywords), mangled to reduce the chances 
of collisions with user macros, or added to the reserved keywords list in 
docs section 6.1.1?


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Buglist 22 Apr 2002 (RC2)
Date: 5 May 2002 13:39:13
Message: <3cd56e41@news.povray.org>
In article <Xns### [at] 204213191226> , che### [at] sympaticoca
(Coridon Henshaw) wrote:

>> Having the same name twice in the same namespace simply cannot work.
>
> Please tell that to the RC3 binary.  It copes just fine with #declared/
> #localed names that match macro parameters:
>
> #local X = function(x,y,z) {x+y+z}
> #macro A(X) #end

But that is a completely different case!  X is known to be a variable in both
cases and the variable namespace is well-defined.

> Given that there's no valid reason to use the output of a macro to
> determine the name of another macro's parameters,

You would be surprised what one can do (also the above can't be done) inside
macro parameter lists...

> not performing macro
> expansion during this portion of parsing seems reasonable for consistancy's
> sake alone.  For instance, why should the code above work when #macro X()
> #end #macro A(X) #end doesn't?

Because macros are in a completely different namespace.  In particular are
#macros behaving like macros and not functions (see <http://www.povray.org/
working-docs/id000153.html#6_2_8_3>) here.

As you know, #locals have a scope that is limited to files or the current
block while #macros are in a global namespace not really shareable with
#declares.  As POV-Ray identifiers are typeless there is significantly more
ambiguity when parsing such constructs.

As for the actual problem, by disallowing #declares (and anything that
implicitly declares an identifier) in parameter lists of #macro definitions
one can allow #macro identifiers as parameter names.  Nevertheless, this might
break some old scenes...

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: John VanSickle
Subject: Re: Buglist 22 Apr 2002 (RC2)
Date: 6 May 2002 18:41:35
Message: <3CD707D1.9A1840B7@hotmail.com>
Coridon Henshaw wrote:
> 
> John VanSickle <evi### [at] hotmailcom> wrote in news:3CD46365.433CEFA3
> @hotmail.com:
> 
> >> Parsing fails on line 248 of shapes.inc when the Spheroid macro
> >> attempts to use 'Center' as a parameter name.
> 
> > A consistent naming scheme will alleviate this problem.
> >
> > For instance, I prefix vector names with a v, scalars with s,
> > index variables with i, and so on.
> 
> This is what I'd call putting the cart before the horse.
> 
> Given that shapes.inc and the other #macro-laden #includes are a
> standard part of the distribution, I tend to think it'd make far more
> sense for them to use a consistant naming scheme to stay out of the
> *users* hair rather than for the user to go through all kinds of
> contortions to stay out of the #include's hair.
> 
> I mean, you wouldn't like the idea of prefixing every name in a C
> program with an underscore (etc) so it wouldn't collide with names
> used by the C RTL, would you?  Of course not.  That's why the
> component names used by C RTL are prefixed with underscores: so the
> user gets virtually the rest of the non-defined namespace to
> himself/herself.

But I also use a consistent naming convention to avoid trampling
my own variables as well.

Regards,
John
-- 
Rusty is rendering!


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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