|
|
"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
|
|