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
28 May 2024 22:07:55 EDT (-0400)
  Re: Next Generation SDL: What's wrong with Lua, JavaScript, ...  
From: nemesis
Date: 12 Apr 2009 11:45:00
Message: <web.49e20c6de7a64ad8bbbb20030@news.povray.org>
"clipka" <nomail@nomail> wrote:
> "MessyBlob" <nomail@nomail> wrote:
> > "clipka" <nomail@nomail> wrote:
> > > But even then I must say that I'd actually not like the syntax -
> > > for POV needs, it would mean an unreasonably large number of
> > > braces-inside-parentheses "({ ... })" where only one type of
> > > brackets would suffice; and a host of "new" statements which -
> > > as proven by current SDL - shouldn't really be necessary.
> > > Not to speak of all the colons (":").
> >
> > There's always the option of inserting a pre-processor into the pipeline,
>
> I guess I'm overusing the word in this thread, but: Yuck!
>
> That one would have to parse the language anyway, wouldn't it? I mean, as long
> as we intend it to increase conciseness instead of adding just more overhead.
>
> Plus, I think it would be nice to have a feature as in JavaScript or Lua to take
> a string and interpret it as a piece of code. A preprocessor wouldn't be able to
> catch that, and people would (righteously) complain why some language constructs
> don't work in that case.

While again not talking that seriously, Lisp macros are known to do just that:
create parsers for new languages with relatively ease.  For instance:

(define-syntax pigment
    (syntax-rules (color-map checker bozo granite marble)
      ((pigment "skel" str)
       (string-append "pigment {" str
                      "}\n"))
      ((pigment checker (x1 y1 z1) (x2 y2 z2))
       (pigment "skel"
         (let ((ns number->string))
           (string-append "checker rgb <" (ns x1)","(ns y1)","(ns z1)
                          "> rgb <" (ns x2)","(ns y2)","(ns z2)">"))))
      ((pigment checker c1 c2)
       (pigment "skel" (let ((ss symbol->string))
                         (string-append "checker color " (ss (quote c1)) " color
" (ss (quote c2))))))
      ((pigment color-map c1 c2 ...)
       (pigment "skel" (string-append "  color_map {\n" #\newline
                                      "  }\n")))))

This should be sufficient to generate a few well-known pattern of use:

> (display (pigment checker black white))
pigment {checker color black color white}
> (display (pigment checker (1 0 0) (0 0 1)))
pigment {checker rgb <1,0,0> rgb <0,0,1>}

Unfortunately, I'm out of time right now... :P


Post a reply to this message

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