POV-Ray : Newsgroups : povray.unofficial.patches : REQ: 'parse' function Server Time
2 Sep 2024 18:20:05 EDT (-0400)
  REQ: 'parse' function (Message 1 to 10 of 10)  
From: Peter Popov
Subject: REQ: 'parse' function
Date: 12 Jul 1999 13:58:46
Message: <378b1e14.33579230@204.213.191.228>
Greetings all.

I just stumbled upon some limitations in the POV language and thought
of a way they could be avoided. These limitations are:

-you can't pass a macro as a parameter of another macro
-POV can't evaluate an expression to a float when reading from a file

The solution I have in mind is a parse(string) function. It simply
inserts the string in the code at the time of parsing (as include
files and macros are treated). So you can to something like:

#macro lissagousFunction(a,b,c)
 ...
#end

#macro connectTheDots(func, foo1, foo2)
 ...
 thisAndThis = parse(func);
 ...
#end

connectTheDots ("lissagousFunction(3,0,1)", 5, 1)

Does it make sense?


Peter Popov
ICQ: 15002700


Post a reply to this message

From: Ken
Subject: Re: REQ: 'parse' function
Date: 12 Jul 1999 14:56:25
Message: <378A39DF.FC6F1F4A@pacbell.net>
Peter Popov wrote:
> 
> Greetings all.
> 
> I just stumbled upon some limitations in the POV language and thought
> of a way they could be avoided. These limitations are:
> 
> -you can't pass a macro as a parameter of another macro
> -POV can't evaluate an expression to a float when reading from a file
> 
> The solution I have in mind is a parse(string) function. It simply
> inserts the string in the code at the time of parsing (as include
> files and macros are treated). So you can to something like:
> 
> #macro lissagousFunction(a,b,c)
>  ...
> #end
> 
> #macro connectTheDots(func, foo1, foo2)
>  ...
>  thisAndThis = parse(func);
>  ...
> #end
> 
> connectTheDots ("lissagousFunction(3,0,1)", 5, 1)
> 
> Does it make sense?
> 
> Peter Popov
> ICQ: 15002700

  Me being the programming and math illeterate bofo that I am I really
don't understand what you are trying to say but I think I understand
what you are trying to accomplish none the less. Instead of the approach
you are suggesting could you not instead store the data produced by the
first macro in an array and use that to pass to the function in the
connectTheDots macro ?


P.S. There is a nice connect the dots macro available at Twyst's MacroScope
collection if you are interested.

http://macroscope.twysted.net/

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Chris Huff
Subject: Re: REQ: 'parse' function
Date: 12 Jul 1999 14:59:04
Message: <378A3C10.641B6D3D@compuserve.com>
All you have to do is write the string to a file and then include the
file. A macro could be made to do this, and use the same syntax.


Post a reply to this message

From: Ron Parker
Subject: Re: REQ: 'parse' function
Date: 12 Jul 1999 15:08:18
Message: <378a3d22@news.povray.org>
On Mon, 12 Jul 1999 14:04:02 -0500, Chris Huff wrote:
>All you have to do is write the string to a file and then include the
>file. A macro could be made to do this, and use the same syntax.

Good idea.  The only caveat, of course, is you wouldn't be able to
parse strings that contain calls to the parse macro.  That might not
be too big a deal, though.


Post a reply to this message

From: Chris Huff
Subject: Re: REQ: 'parse' function
Date: 12 Jul 1999 18:01:36
Message: <378A66D7.DB4AC91B@compuserve.com>
>Good idea.  The only caveat, of course, is you wouldn't be able to
parse strings that contain calls to the parse macro.  That might not
be too big a deal, though.<

Why not? Macros are capable of recursion, and it would be possible to
set it up to use different files for each macro call, wouldn't it?


Post a reply to this message

From: Nathan Kopp
Subject: Re: REQ: 'parse' function
Date: 12 Jul 1999 22:34:04
Message: <378AA47B.88F7C8FD@Kopp.com>
The way the parser is currently written, this would not be trivial to
add, IMHO.  Chris' suggestion is good, though (although maybe a bit slow?).

-Nathan


Peter Popov wrote:
> 
> Greetings all.
> 
> The solution I have in mind is a parse(string) function. It simply
> inserts the string in the code at the time of parsing (as include
> files and macros are treated). So you can to something like:


Post a reply to this message

From: Peter Popov
Subject: Re: REQ: 'parse' function
Date: 13 Jul 1999 00:28:12
Message: <378cbf8f.74923820@204.213.191.228>
The way I am currently doing it is the way Chris offers. The problem
is that I need a good 20000 or more calls of this kind, and it gets
slow, really.

Anyway, for the purpose I need it, I should confine to official POV
only, so that's the only way to go right now. Thank you guys.


Peter Popov
ICQ: 15002700


Post a reply to this message

From: Ron Parker
Subject: Re: REQ: 'parse' function
Date: 13 Jul 1999 09:09:59
Message: <378b3aa7@news.povray.org>
On Mon, 12 Jul 1999 22:29:15 -0400, Nathan Kopp wrote:
>The way the parser is currently written, this would not be trivial to
>add, IMHO.  Chris' suggestion is good, though (although maybe a bit slow?).

Funny you should say that.... Before I read Chris' suggestion, I went
to see how hard it would be to implement and it didn't look too 
difficult to do at least the nonrecursive case.  OTOH, it wouldn't be 
much faster than Chris' suggestion, so why make changes to the code?


Post a reply to this message

From: Axel Hecht
Subject: Re: REQ: 'parse' function
Date: 13 Jul 1999 09:22:53
Message: <378B3D92.4087CF2E@numerik.uni-kiel.de>
Peter Popov wrote:
> 
> The way I am currently doing it is the way Chris offers. The problem
> is that I need a good 20000 or more calls of this kind, and it gets
> slow, really.
> 
> Anyway, for the purpose I need it, I should confine to official POV
> only, so that's the only way to go right now. Thank you guys.
> 
> Peter Popov
> ICQ: 15002700


Perhaps using a temporary file can speed things up. Working on a unix
box, this would be on a ram disk, skipping all the hard disk handling.

Axel


Post a reply to this message

From: Chris Huff
Subject: Re: REQ: 'parse' function
Date: 13 Jul 1999 20:06:49
Message: <378BD5B1.575534FD@compuserve.com>
Yes, a RAM disk(that term is also used on the Mac) would definitely
better here. (now why didn't I think of that?)

Funny how different platforms use completely different language for the
exact same thing. (I like folder better than directory, though.)


Post a reply to this message

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