POV-Ray : Newsgroups : povray.pov4.discussion.general : Next Generation SDL: What's wrong with Lua, JavaScript, ... : Re: Next Generation SDL: What's wrong with Lua, JavaScript, ... Server Time
15 May 2024 12:51:30 EDT (-0400)
  Re: Next Generation SDL: What's wrong with Lua, JavaScript, ...  
From: BSDero
Date: 9 Oct 2009 13:55:00
Message: <web.4acf786ae7a64ad8d8582c2a0@news.povray.org>
I'm working on my own little raytracer to play with, and I know some programming
languages, and *yes* povray one.

I've designed a little language, and interpreter (VM) using flex, bison, gcc and
those gnu tools. Most of simple lang is working ok, but I would like an approach
like this:
-------------------------------------

$camera = ::renderer.camera

with( $camera){
 .loc =  <2, 5, -10>
 .lookat = <0>
}

with ( new Lit() ){
 .loc = <0, -10, 0>
 .color = <1.0>
}

//u can create objects and directly assign'em values. Note there is not
//variables, object references or whatever, in some povray-ish manner
with ( new Sphere() ){
 .geom = <0>, 5
 .pigment = <1.0,0.0,0.0>
}

//or took the traditional more programming approach
$obj_sphere = new Sphere()
with( $obj_sphere){
 .geom = <15, 0, 0>, 2
}

//just decided to let this, for animations. Maybe would be ok on a for loop
::renderer.render()
----------------------------------------------
i think it's ok, this is just one of the things i've working right now, and it
has not too hard to do.





"clipka" <nomail@nomail> wrote:
> "MessyBlob" <nomail@nomail> wrote:
> >
> > Doesn't JavaScript have the ability to assign properties to objects as they are
> > being instantiated?, e.g.
> >
> > Sph = new Sphere( {
> >   radius: 1,
> >   position: [0,0,1]
> > } );
>
> A host of languages has this.
>
> The problem is still the scope: However you toss and turn it, you can't just go
> ahead and do some stuff in the new object's scope (or "namespace" or however
> you want to call it) without some added hassle.
>
> The problem is that all mainstream languages do initialization of an object by
> passing some expressions as parameters, with the expressions being evaluated in
> the scope of the calling block. Plus they're evaluated before the object is
> created, so can't have side effects on the object.


Post a reply to this message

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