POV-Ray : Newsgroups : povray.advanced-users : dot-notation not allowed in functions? Server Time
29 Mar 2024 10:40:09 EDT (-0400)
  dot-notation not allowed in functions? (Message 11 to 15 of 15)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: clipka
Subject: Re: dot-notation not allowed in functions?
Date: 31 Jul 2018 15:36:14
Message: <5b60ba2e$1@news.povray.org>
Am 31.07.2018 um 20:31 schrieb Thorsten Froehlich:

>> That said, "as designed and documented" doesn't necessarily mean that
>> it's free from issues that might warrant fixing. It might just be that
>> there's a problem with the design.
>>
>> And I for one would argue that that's indeed the case (presuming dot
>> notation has been excluded from functions by design rather than by
>> oversight). Because - evidently - this behaviour goes against user
>> expectations.
> 
> It is logically correct in a properly (given you worked on the tokenizer you
> know what I mean) designed parser: Functions cannot access declared values
> because functions persist after parsing. This would require substituting the
> preprocessor-level declared variable with the value of the variable. This value
> would be a vector, which isn't supported.

I don't see an issue there.

It would be a valid point if the dot operator were to be implemented as
an operation in the function VM.

However, since we are talking about `SDL_VARIABLE.x` (and siblings)
here, and not `FUNCTION_PARAMETER.x`, I see no sound reason why the
function parser couldn't resolve the operation at parse-time.

The rule would be pretty simple:

If the token is an SDL variable holding a vector or colour, take a peek
at the next token. If that token is a dot, expect a component name, and
inject the respective value into function. If the token is not a dot (or
the component name is invalid), raise an error.


Post a reply to this message

From: Kenneth
Subject: Re: dot-notation not allowed in functions?
Date: 31 Jul 2018 17:05:01
Message: <web.5b60ceea497a6101a47873e10@news.povray.org>
"Thorsten Froehlich" <nomail@nomail> wrote:

>
> No, expecting spoon-feeding is the socially unacceptable behavior...

Ah, the ol' spoon-feeding reposte.

Well, even Einstein had to be spoon-fed every now and then (by Marcel Grossman)
with arcane maths knowledge that he didn't know. If MC had used the "RTFM"
method instead, we may never have had the General Theory Of Relativity! (ha!)
>
> > "Note: Only the above mentioned items can be used in user-defined functions.
> > For example the rand() function is not available."
>
> Yes, that is completely odd and I have no idea why this is in the documentation.
>
But don't take it out!!

And add dot-notation.

:-P


Post a reply to this message

From: Kenneth
Subject: Re: dot-notation not allowed in functions?
Date: 2 Aug 2018 13:45:07
Message: <web.5b6342a6497a6101a47873e10@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> Ah, the ol' spoon-feeding reposte.
>

Oops.

"riposte"

If I'm going to use a high-brow literary word, I guess I should first learn how
to spell it... :-O


Post a reply to this message

From: Bald Eagle
Subject: Re: dot-notation not allowed in functions?
Date: 2 Aug 2018 15:05:01
Message: <web.5b63551f497a6101c437ac910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> If I'm going to use a high-brow literary word, I guess I should first learn how
> to spell it... :-O

Yeah.  That's the Epi-TOME of ignorance.   :D


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: dot-notation not allowed in functions?
Date: 3 Aug 2018 12:55:01
Message: <web.5b6488b0497a6101e31d9a330@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> I don't see an issue there.

Well, I implemented that part of the parser, and I do ;-)

> It would be a valid point if the dot operator were to be implemented as
> an operation in the function VM.

The dot operator isn't the problem. The preprcessor declares, locals and macro
argument names are.

> However, since we are talking about `SDL_VARIABLE.x` (and siblings)
> here, and not `FUNCTION_PARAMETER.x`, I see no sound reason why the
> function parser couldn't resolve the operation at parse-time.
>
> The rule would be pretty simple:
>
> If the token is an SDL variable holding a vector or colour, take a peek
> at the next token. If that token is a dot, expect a component name, and
> inject the respective value into function. If the token is not a dot (or
> the component name is invalid), raise an error.

Good luck trying. You end up making a copy of most of the identifer parser code
to support this, with lots of modifications to code that is already one of the
most fragile pieces of the regular parser, just to exclude macros and other
unwanted features getting in the way. Of cource it would "work", just that the
code would be a nightmare to support.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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