POV-Ray : Newsgroups : povray.general : POV-Ray & Databases : Re: POV-Ray & Databases Server Time
2 Aug 2024 16:28:03 EDT (-0400)
  Re: POV-Ray & Databases  
From: Christopher James Huff
Date: 5 Nov 2004 21:10:17
Message: <cjameshuff-661456.21102505112004@news.povray.org>
A better use for "is" might be checking whether two objects are really 
references to the same one. The more traditional word is "isa":
if(SomeObject isa union)

Also, the parentheses around the foreach parameters don't really do 
anything. Anyway, an alternative I prefer uses a structure called a 
block which is similar to a function passed as a parameter. A syntax 
based on C++ or Java might look a bit like:

MyUnion.foreach( #(Obj){...do stuff with Obj} );

The thing is, this gives you many more possibilities. You could create 
foreach() methods for your own data structures, you could use blocks to 
give comparison functions to sort algorithms, etc...

If numbers are first class objects, that makes some other things much 
easier as well. Say you have a .. operator that makes a list from a 
given start and end value:

(3..7).foreach( #(n){debug(n)} );

Or say numbers have a "times()" method that calls a block n times:

5.times( #debug("Hello!") );

Personally, I prefer the syntax I used in Sapphire, based off languages 
like Self and Smalltalk:

(3..7) foreach: #(n){debug(n)};

5 times: #debug("Hello!");

However, this is likely to just look too weird to most people...took me 
a while to decide I preferred it. It tends to be more self documenting, 
though:

foo.setColorRGB(0.2, 0.6, 0.8);

would translate to:

foo setColorR:0.2 G:0.6 B:0.8;

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

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