POV-Ray : Newsgroups : povray.general : return dictionary from macro [bug?] : Re: return dictionary from macro [bug?] Server Time
25 Sep 2021 07:49:04 EDT (-0400)
  Re: return dictionary from macro [bug?]  
From: William F Pokorny
Date: 15 Apr 2021 11:59:02
Message: <607862c6$1@news.povray.org>
On 4/14/21 1:44 PM, ingo wrote:
> in news:6076e733$1@news.povray.org William F Pokorny wrote:
> 
>>> //-----------
>>> #version 3.8;
>>>
>>> #macro SomeThing(A)
>>>     #local RD = dictionary;
>>>     RD
>>> #end
>>>    
>>> #declare SD = SomeThing(1);
>>> //-----------
>>>
>>
>> I'm confused as to what you are trying to do. Not myself used
>> dictionaries much as yet, but it looks to me like you are after:
> 
> The goal is to build a datastructure with the macro to pass around. After
> eliminating everything in the body of the macro this is what's left.

Perhaps it would be simpler for the macro body to just be:

#macro...
dictionary {
...
}
#end

I do not see the reason for the local variable RD, though it 'should' 
always work - or always fail, if illegal to do.

> 
> Haven't tried other versions of POV-Ray yet. Fiddling with something else.
> Will try soon as my old brain starts to remember discussing this with
> clipka before, .. I think.
> 

Might not be worth your time. I think the land mine is sitting there 
with dictionaries no matter the version.

We can debug with simpler SDL. Further, if v3.8 master is compiled with 
POV_DEBUG set and the RD dictionary is set up with a few defaults, v3.8 
based version reliably trips a hard, debug, parser panic assertion.

This means there are at least a couple things wrong when doing 
assignments like #declare SD = RD; with dictionaries.

The original povr segfault (when I hit it) is during a pointer 
assignment during the parser clean up. The panic test which fails is 
couple lines below it, doing a reference>0 check. (Moving the test prior 
to the assignment doesn't roll up the segfault)

// ./configure COMPILED_BY="wfp" CXXFLAGS="-DPOV_DEBUG"
//-----------
#version 3.8;

// #local RD = dictionary;

    #local RD = dictionary {
        .foo: "this is nice.",
        .bar: 12345
    }

    #declare SD = RD;

    #error "Stop after parsing"
//-----------

Aside 1: the array code has special empty array handling, which doesn't 
exist for dictionaries. Perhaps it should...?

Near term. If using dictionaries, I'd recommend configuring and 
compiling with POV_DEBUG defined no matter the version - some protection 
in that.

Aside 2: The segfault and POV_DEBUG assertion is during parser clean up. 
However, I don't understand the related code well enough to know whether 
or not there might be situations where dictionaries might be 'running' 
OK, but not always behaving as they should. Users beware.

Unsure how long it might take me to unravel the dictionary parsing code 
well enough to understand the problems - let alone fix them...

Bill P.


Post a reply to this message

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