POV-Ray : Newsgroups : povray.general : Feature requests iden() Server Time
8 Aug 2024 18:20:10 EDT (-0400)
  Feature requests iden() (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
From: Rune
Subject: Feature requests iden()
Date: 26 Nov 2000 07:50:48
Message: <3a210728@news.povray.org>
iden( string )

Turns a string into an identifier.

For example:

#declare iden("ThisFloat") = ThatFloat*2;

or

#declare ThisFloat = iden("ThatFloat")*2;

I find myself often need such a feature *very* much!

Please, anyone? :)

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Christoph Hormann
Subject: Re: Feature requests iden()
Date: 26 Nov 2000 08:23:06
Message: <3A210EBA.9B3A290F@gmx.de>
Rune wrote:
> 
> iden( string )
> 
> Turns a string into an identifier.
> 
> For example:
> 
> #declare iden("ThisFloat") = ThatFloat*2;
> 
> or
> 
> #declare ThisFloat = iden("ThatFloat")*2;
> 
> I find myself often need such a feature *very* much!
> 
> Please, anyone? :)
> 
> Rune

I'm not sure if that's easy to implement, furthermore it's likely to
produce errors because the string can change during eveluation of the Pov
code.

BTW, i don't know any programming language that has such a function.

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Chris Colefax
Subject: Re: Feature requests iden()
Date: 26 Nov 2000 09:00:06
Message: <3a211766@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> I'm not sure if that's easy to implement, furthermore it's likely to
> produce errors because the string can change during eveluation of the Pov
> code.
>
> BTW, i don't know any programming language that has such a function.

I would imagine that the ability to change the string dynamically during the
parsing of the script is precisely the reason Rune would like a function
like this!  And it's not unheard of - PHP, for instance, allows variable
variables, i.e. you can have one variable $a = "name", then use $$a just as
if it were $name.


Post a reply to this message

From: Rune
Subject: Re: Feature requests iden()
Date: 26 Nov 2000 11:49:45
Message: <3a213f29@news.povray.org>
The iden() feature would be perfect in situations where arrays aren't
flexible enough.

An array like this

FlexArray[X][Y]

could be made like this

iden( concat( "FlexArray", str(X,0,0), "x", str(Y,0,0) ) )

However, in arrays all the elements have to be of the same data type. Not so
with the iden solution.

Arrays are confined to the number of elements you initiate it with. Not so
with the iden solution.

With arrays you are limited to the dimensions you set. All rows and columns
must have the same number of elements. With the iden solution you can make
up a completely custom structure.

These are just some of the many possibilities with the iden() feature. Don't
hesitate, buy it today! Err, I mean, program it today! :)

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Chris Huff
Subject: Re: Feature requests iden()
Date: 26 Nov 2000 12:58:10
Message: <chrishuff-4DAD1F.12584126112000@news.povray.org>
This looks like a potentially powerful feature...I don't know how easily 
it could be done, but it shouldn't be impossible or very difficult.

It might allow the creation of a kind of "OOP" system written entirely 
in POV-Script...though that would be a very slow and clumsy way to do it.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Ron Parker
Subject: Re: Feature requests iden()
Date: 26 Nov 2000 13:23:01
Message: <slrn922l87.h5k.ron.parker@fwi.com>
On Sun, 26 Nov 2000 13:49:15 +0100, Rune wrote:
>iden( string )
>
>Turns a string into an identifier.

I think I'd rather see associative arrays a la perl.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Warp
Subject: Re: Feature requests iden()
Date: 27 Nov 2000 03:13:05
Message: <3a221791$1@news.povray.org>
#macro iden(String)
  #fopen TmpFile "tmptmp.tmp" write
  #write(TmpFile, String)
  #fclose TmpFile
  #include "tmptmp.tmp"
#end


  You can then use it exactly as you wanted:

#declare iden("ThisFloat") = ThatFloat*2;

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Rune
Subject: Re: Feature requests iden()
Date: 27 Nov 2000 11:20:38
Message: <3a2289d6@news.povray.org>
"Warp" wrote:
> #macro iden(String)
>   #fopen TmpFile "tmptmp.tmp" write
>   #write(TmpFile, String)
>   #fclose TmpFile
>   #include "tmptmp.tmp"
> #end

I had been thinking about using #write and #include some way or another to
solve my problem, but your solution is just perfect!

Thank you Warp, you have spared me for a lot a trouble. :)

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Chris Huff
Subject: Re: Feature requests iden()
Date: 27 Nov 2000 16:43:38
Message: <chrishuff-AB3F53.16440827112000@news.povray.org>
I had briefly considered writing to a file and then including it, but 
didn't think it would work in all cases, because including a file or 
calling a macro doesn't do a direct copy and paste...can you use it in 
macro parameters?
That macro is a great way of getting it done now, but a built-in feature 
wouldn't leave that temporary file hanging around...a minor 
inconvenience, but annoying, especially if it conflicts with another 
file, though that isn't likely...maybe something like "identinc.tmp" 
would be better.

Anyway, another potential addition for the macros to be included with 
POV 3.5, don't you think? It's going in my personal collection...

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Chris Huff
Subject: Re: Feature requests iden()
Date: 27 Nov 2000 16:45:18
Message: <chrishuff-BECC7B.16455027112000@news.povray.org>
In article <slr### [at] fwicom>, ron### [at] povrayorg 
wrote:

> I think I'd rather see associative arrays a la perl.

Maybe Warp can implement that as a macro... :-)
Could you give more information on what the syntax would be like? Aren't 
associative arrays just structures that "associate" a string or hash 
with a variable?

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

Goto Latest 10 Messages Next 9 Messages >>>

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