POV-Ray : Newsgroups : povray.pov4.discussion.general : Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0) Server Time
27 Jul 2024 12:31:43 EDT (-0400)
  Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0) (Message 11 to 20 of 25)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 5 Messages >>>
From: Bald Eagle
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 28 Jun 2024 09:30:00
Message: <web.667eba654bc5dc75e21e5c0b25979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> > > I'm thinking a keyword modifier would be more flexible than a directive,
> > > for example:
> > >
> > >   #declare const GlobalVal = 12345;
> > >   #local const LocalVal = 54321;
>
> "modifier", yes.  +1.



>
> > Hmmm.   Yes, but maybe no?
> > Why not just have another separate type of declaration?
>
> the keyword modifier, more often than not I think, would be in close proximity
> to the variable where/when it's used.  an advantage.

In the absence of a concrete example, I'm wondering how the modifier would be
"more flexible", and what "close proximity to the variable where/when it's
used." means.

> > ...
> > So maybe #constant can ONLY be changed by specifically using another #constant
> > directive.
>
> if a variable's value can/will change "at runtime", #constant would simply be
> misleading.

Sort of.  I think the underlying idea is that it's not forever immutable, but
protected from unintentional and silent reassignment of it's value.

What about #protected?
It could be like function {}, where once declared, the parser throws an
(intelligible) error unless it's #undef'd before redeclaring.

The trick is balancing ease-of-coding with good coding practices, and new-user
friendly syntax so that we don't further steepen the learning curve.


> maybe "4.x" could have a revamped "SDL 2.0", with more "introspection" tools, so
> we can write better, "type safe" code.

Well YES.  Those sorts of things have long been wanted.
Camera location keyword/identifiers that would function like image_height, etc.
Identifier typing, especially for use in #read.
Differentiating things like vectors of different sizes, floats, etc.
View frustum coordinates or an internally defined 3D view frustum (maybe an
internal function that takes a length for the direction vector) that one can do
inside () tests with.

What really needs to be done is to draw a "map" of what we have coupled with
what we'd like to see.  That would function as a brainstorming vehicle, and a
to-do list.

Macros that people have written over the decades could be used as inspiration,
and I'm sure there are code libraries and things on GitHub, etc that have actual
c++ code or whatever language 4.x will be written in.


- BW


Post a reply to this message

From: William F Pokorny
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 28 Jun 2024 09:40:40
Message: <667ebd58$1@news.povray.org>
On 6/28/24 01:13, ingo wrote:
> William F Pokorny <ano### [at] anonymousorg> wrote:
> 
> 
> #macro Add(_immuInt, otherInt)
> ......
> #end
> 
> #declare Res = Add(99,1)
> 
> #declare _immu = 99;
> 
> #declare Res = Add(_immu, 1)
> 
> In the second use of the macro, would it be required that the 'referenced' value
> is also declared immutable?
> 
> ingo
> 

If I'm understanding you, no with respect to the macro, identifier pass 
by reference issue.

As long as you have _immuInt as the first macro Add() parameter name, 
the call can be Add(_immu,1) or Add(Res,1) and neither _immu or Res can 
be changed by any #local or #declare use of _immuInt inside the macro.

That said, the Res identifier is not protected from someone writing:

     #declare Res = 42;

inside the macro while  	

     #declare _immu = 42;

will be illegal inside the Add() macro. So, it's not necessary the _ 
prefix immutability be indicated in both the macro parameter and more 
global calling space - but it is a good idea, if you want protection 
from someone making more global changes from within the macro.

Related. The hole in the prefix based constant-ness is that it is NOT 
propagated into macros called. For example,

#macro Add(V1,V2)
     #local V1 = V1+V2;
     V1
#end

    #declare _immu = 42;
    #declare Val99 = Add(_immu,1);

will still result in the _immu getting clobbered. The best practice 
would be to always use macro parameter names with the _ prefix - unless 
you are truly aiming to change identifiers by reference inside the 
macro.

Bill P.


Post a reply to this message

From: tTh
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 28 Jun 2024 11:51:01
Message: <667edbe5$1@news.povray.org>
On 6/28/24 00:47, Cousin Ricky wrote:

>> Release R15 of the yuqk fork has an implementation supporting constant
>> identifiers / macro parameters. They are indicated by using a leading
>> '_' character in the name.

    Mmmm, this can break some of my code /o\

> I also agree with Ingo: a keyword or directive would be better, such as:
> 
>    #const MagicNumber = 12345;

    [like]

-- 
+---------------------------------------------------------------------+
|          https://tube.interhacker.space/a/tth/video-channels        |
+---------------------------------------------------------------------+


Post a reply to this message

From: jr
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 01:00:00
Message: <web.667f94264bc5dc75c7a7971d6cde94f1@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > > > [Cousin Ricky]
> > > > I'm thinking a keyword modifier would be more flexible than a directive,
> > > > for example:
> > > >
> > > >   #declare const GlobalVal = 12345;
> > > >   #local const LocalVal = 54321;
> >
> > "modifier", yes.  +1.
>
> > > Why not just have another separate type of declaration?
> >
> > the keyword modifier, more often than not I think, would be in close proximity
> > to the variable where/when it's used.  an advantage.
>
> In the absence of a concrete example, I'm wondering how the modifier would be
> "more flexible", and what "close proximity to the variable where/when it's
> used." means.

the "close proximity" thing is shown in CR's suggestion, note the 'const'
immediately in front of the variable in question.

"flexible", for instance, a (say) '#constant' directive alone and the macro
definition would still offer no "visual clues" wrt the arguments also could not
be used in expressions either.

(and remember, I'm no "language designer" either :-))


> > if a variable's value can/will change "at runtime", #constant would simply be
> > misleading.
> Sort of.  I think the underlying idea is that it's not forever immutable, but
> protected from unintentional and silent reassignment of it's value.
> What about #protected?
> It could be like function {}, where once declared, the parser throws an
> (intelligible) error unless it's #undef'd before redeclaring.

see reply to WFP.


> The trick is balancing ease-of-coding with good coding practices, and new-user
> friendly syntax so that we don't further steepen the learning curve.
>
> > maybe "4.x" could have a revamped "SDL 2.0", with more "introspection" tools, so
> > we can write better, "type safe" code.
>
> Well YES.  Those sorts of things have long been wanted. ...
> What really needs to be done is to draw a "map" of what we have coupled with
> what we'd like to see.  That would function as a brainstorming vehicle, and a
> to-do list.

agree, a in-one-place collection of things needing doing, plus "feature
requests", is very much needed.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 01:05:00
Message: <web.667f94f34bc5dc75c7a7971d6cde94f1@news.povray.org>
hi,

just a couple of thoughts.

William F Pokorny <ano### [at] anonymousorg> wrote:
> ...
> One day, not long ago, it hit me that maybe identifier prefixes would be
> a way we could implement reasonably broad, useful constant-ness - ...
>
> Given I'm going to delay to implement a build configuration option for
> this feature, do you think some other prefix would be better? ('_r',
> 'ro_', 'r_', ?)

"democracy" eh ?! </grin>.  given those options, 'ro_' would be my choice, as
it's "mnemonic".


> Aside 1: I have still bugs and issues with the current global / local
> dictionary behavior in v3.8+ to sort... Our implementation doesn't match
> our documentation and we probably need a #top (or #upid (upvar n))
> directive alongside #directive and #local.

having read ingo's Nim language examples, I really like the "everything is
immutable unless" approach.  safe.  perhaps all macro args (as you wrote
somewhere) ought to be "ro" by default, and an explicit 'upvar N' required for
every exception ?  (that (upvar N) :-) would be _seriously_ nice to have)


regards, jr.


Post a reply to this message

From: William F Pokorny
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 14:36:26
Message: <6680542a$1@news.povray.org>
On 6/29/24 01:00, jr wrote:
> hi,
> 
> just a couple of thoughts.
> 
> William F Pokorny <ano### [at] anonymousorg> wrote:
>> ...
>> One day, not long ago, it hit me that maybe identifier prefixes would be
>> a way we could implement reasonably broad, useful constant-ness - ...
>>
>> Given I'm going to delay to implement a build configuration option for
>> this feature, do you think some other prefix would be better? ('_r',
>> 'ro_', 'r_', ?)
> 
> "democracy" eh ?! </grin>.  given those options, 'ro_' would be my choice, as
> it's "mnemonic".
> 

Yeah, and ro_ fits with my keyword prefix direction too.

> 
>> Aside 1: I have still bugs and issues with the current global / local
>> dictionary behavior in v3.8+ to sort... Our implementation doesn't match
>> our documentation and we probably need a #top (or #upid (upvar n))
>> directive alongside #directive and #local.
> 
> having read ingo's Nim language examples, I really like the "everything is
> immutable unless" approach.  safe.  perhaps all macro args (as you wrote
> somewhere) ought to be "ro" by default, and an explicit 'upvar N' required for
> every exception ?  (that (upvar N) :-) would be _seriously_ nice to have)
> 

I've been thinking about those examples too & my response to Ingo's 
question. I failed / bailed on my initial attempts to make a macro 
parameters constant always - but success would have meant a SDL change 
much more likely to break current code than an 'ro_' prefix. I hadn't 
thought much at all about a keyword to change defaulted read-only to 
something mutable via a new keyword.

It might be we could check that the mutability of the parameter in the 
macro matches the caller's ID mutability, but there are limits to how 
much checking like that we can do given SDL isn't compiled and linked. 
We'd be paying the price of the overhead on every call to the macro.

 From what I've seen people mostly use the macro 'pass by reference and 
change' and '#declare ID' as mechanisms to return multiple values or to
define what they want global as with the yuqk munction concept compiling 
users functions only once. (We now have the tuple return and assignment 
mechanisms in v3.8.)

Another thing which might be possible nearer term, would be to make 
mixed use of #declare and #local with the same variable name inside 
macros illegal in yuqk (or in just the debug compile).

See the attached file for a few examples of how mixing one identifier 
name with both #local and #declare can result in instability. The macro 
parameter - change by reference - issue aside.

We should mention too, for those stumbling across this thread later, 
that a good solution for all the macro-ish exposures to inadvertent 
identifier change is to use functions when dealing with just math and a 
return a value.

Bill P.


Post a reply to this message


Attachments:
Download 'instabilitywithlocalanddeclareuse.txt' (3 KB)

From: Bald Eagle
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 14:55:00
Message: <web.668057a14bc5dc751f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> agree, a in-one-place collection of things needing doing, plus "feature
> requests", is very much needed.

Well, this has been brought up by myself and other before,

I think the easiest thing to do would simply be use a collaboration tool or
project management tool and get _something_ started.

https://opensource.com/business/15/7/five-open-source-alternatives-google-docs


Then we could start with a general outline of what we _have_ complete with
hyperlinks to the wiki or whatever works best to illustrate the concept.

Then maybe separate documents that "mirror" the source code, where we could
strip out all of the extraneous non-code stuff, for enhanced readability (with
links to original).  Then people with coding experience could read and comment
on the code, and perhaps even insert hyperlinks between where one piece of code
utilizes a variable, and the (faraway) place in the code where that variable
gets updated last.

Obviously to-do list and desired features.
Coders could begin scribbling scratch code and other people could be inspired
and take it a step further.

The advantage here is that if the outline structure is maintained well, it'll be
a lot easier to find than sifting through 30 years of haphazard forum posts.

Users could then have a personal "wiki page".

FAQ type material could be organized to provide "one code example for every
keyword", micro-tutorials on coding methods / algorithms / tricks, working
examples of tricky syntax, etc.

Macros could be assembled so that people could look things up in an index and
find what they were looking for.
Desired features could be exemplified with macros, and then converted to source
code by people who have the c++ experience but don't understand the goal /
algorithm needed.

And since it should pretty much be all text, with hyperlinks to graphics,
articles, pdf documents, websites, etc, it should be fairly small to store local
copies - which means every collaborator has a copy / backup.

- BW


Post a reply to this message

From: jr
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 15:40:00
Message: <web.668062ca4bc5dc75c7a7971d6cde94f1@news.povray.org>
hi,

William F Pokorny <ano### [at] anonymousorg> wrote:
> ...

a lot of points/issues "touched on", food for thought.  will, in the coming
days, try and set out the response "gut feeling" tells me, structured, for your
inbox.



@Bald Eagle.
> Users could then have a personal "wiki page".

a wiki s/ware would be perfect.  personally, I think 'fossil' should "be on the
table".


> ... it should be fairly small to store local copies ...

no need to worry, in this day and age.  (the machine which took the place of the


common access will be the "bug bear" imo.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 16:35:00
Message: <web.66806fcd4bc5dc751f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> a wiki s/ware would be perfect.  personally, I think 'fossil' should "be on the
> table".

I'm game.  I can download that and we can see about getting something started.

> (the machine which took the place of the common access will be the "bug bear" imo.

We are truly 2 people separated by a common language.

- BW


Post a reply to this message

From: jr
Subject: Re: Suggest v4.0 read only identifiers. (yuqk R15 v0.6.9.0)
Date: 29 Jun 2024 17:20:00
Message: <web.668079b44bc5dc75c7a7971d6cde94f1@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
>
> > a wiki s/ware would be perfect.  personally, I think 'fossil' should "be on the
> > table".
>
> I'm game.  I can download that and we can see about getting something started.

<https://www.fossil-scm.org/home/doc/trunk/www/index.wiki>


> > (the machine which took the place of the common access will be the "bug bear" imo.
>
> We are truly 2 people separated by a common language.

</grin>.  "struggling against the same s/ware configuration", more like.
apparently, the GBP currency sign (too) makes the web l/f "unhappy"; I wrote,
"showing off", that crow's "replacement" has 1.5T (truly mind-boggling "space",
on two M.2 SSDs), for under 100 of our currency units; cheaper still now.


regards, jr.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 5 Messages >>>

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