What does the simplified sexp-based syntax for C# looks like?
- From: Joel Reymont <joelr1@xxxxxxxxx>
- Date: Wed, 25 Mar 2009 14:53:55 -0700 (PDT)
On Mar 25, 9:37 pm, p...@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
wrote:
It's good. You could also use CLOS objects. That's what I do because
anyways I defined my own macros to define these classes since in the
language I was concerned with (C++), there are several categories of
these classes.
It's more of a question of struct vs sexp but you have responded to
that below.
It would depend. If you start from a source in your "trading
language", parse it, and produce the parse tree from it, then you
don't have to write functions such as this OCaml example. Your parse
trees are built dynamically from the source language parsing.
I lex, parse, produce the trading language parse tree and transform it
into the C# AST. I do have to write functions like my OCaml example
both to pre-populate the target C# class with code that's always
present, and to set up the tests.
I have an extensive test harness that ensures my transformations are
correct by comparing the C# AST I produce against one that I expect.
That OCaml code is just an AST helper.
On the other hand, if you want to be able to write easily C# routines
from Lisp, then I would advise to define a s-exp based simplified
syntax for C#.
My original post has the wrong title and has a typo. The real title
should be "What does the simplified sexp-based syntax for C# look
like?" :-).
You'd implement this syntax as a set of macros (and
possibly functions) that would expand into these structure (or object)
instanciations.
Right.
I would never write in lisp something like your OCaml function above,
but rather write a s-exp such as:
(define-method point-size ((bip int)) double :protected
(return (dot (dot (dot (aref bars-array bit) instrument)
master-instrument) point-value)))
Bingo, thanks Pascal!
Now, what would a C# class sexp look like? It also needs fields and
properties. The latter are a bit of a pain:
[Description("")]
[Category("Parameters")]
public int PointsRisked
{
get
{
return pointsRisked;
};
set(int value)
{
pointsRisked = value;
};
}
Thanks, Joel
.
- Follow-Ups:
- Re: What does the simplified sexp-based syntax for C# looks like?
- From: Mark Wooding
- Re: What does the simplified sexp-based syntax for C# looks like?
- From: Pascal J. Bourguignon
- Re: What does the simplified sexp-based syntax for C# look like?
- From: Joel Reymont
- Re: What does the simplified sexp-based syntax for C# looks like?
- References:
- what would c# loop like in lisp?
- From: Joel Reymont
- Re: what would c# loop like in lisp?
- From: Pascal J. Bourguignon
- what would c# loop like in lisp?
- Prev by Date: Re: what would c# loop like in lisp?
- Next by Date: Re: Immutable conses and pain
- Previous by thread: Re: what would c# loop like in lisp?
- Next by thread: Re: What does the simplified sexp-based syntax for C# look like?
- Index(es):
Relevant Pages
|