POV-Ray : Newsgroups : povray.programming : language design (was Re: hash marks) : Re: language design (was Re: hash marks) Server Time
28 Jul 2024 16:21:41 EDT (-0400)
  Re: language design (was Re: hash marks)  
From: Vadim Sytnikov
Date: 15 Mar 2002 10:12:47
Message: <3c920f6f$1@news.povray.org>
> Given the example he gave is not
> pre-processes but would be allowed by the language, where exactly would be
> the problem?

The example that ABX gave us would *not* work in a language that has normal
scope rules (which even BASIC and Fortran have these days -- to some
extent). Below, left (opening) parenthesis opens scope for the 'sphere'
statement. If the 'if' and 'else' keywords were true language statements,
and not merely pre-processor directives, then it would be necessary to have
a right (closing) parenthesis before the 'else' statement.

>   if(z>0)
>      sphere{0 1
>                ^-------- (A)
>   else

That is, if we had a consistent language, the example should have looked
like this (extra parentheses added to just make scopes more clear; I do not
insist language syntax should necessarily require that):

if( z>0) {
  sphere {
    // sphere definition goes here
  }
} else {
  // another shape definition
}

In other words, the 'sphere' scope should have been closed before the 'else'
keyword. Therefore, transform definition should have been specified before
the 'else' keyword as well. Therefore, the only way to avoid duplicating
transform definition would be to declare it beforehand, and then reference
from within sphere definition, etc. (as I wrote earlier).


Post a reply to this message

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