What does the simplified sexp-based syntax for C# looks like?



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
.



Relevant Pages

  • Re: Very poor Lisp performance / about Mathematica
    ... >> You cannot predict what such an OCaml program will do. ... Not using them is considered an abuse of the language. ... I wouldn't apply any of that theory to Mathematica directly. ...
    (comp.lang.lisp)
  • Re: Up to date MFC Book
    ... To the developers what matters is that they are comfortable with the language, ... and so is difficult for tools to parse and process ... ... parse the compiler has to do is different from the parse that a refactoring tool ... OO design principles) is that it wraps the Win32 API enough to let you do what ...
    (microsoft.public.vc.mfc)
  • Re: writing data adapter sql commands
    ... MySqlCmdBuilder.QuoteSuffix = "]" to my form load event and like you said it works with out needing to parse the insert statement. ... I really don't understand why I need to set parameters and I'm not using ADO.Net. ... language related problems, but ADO.Net is nothing that is related to the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: newbie: m-expressions
    ... > Now I can parse my language and translate it to Lisp...but if there is ... > a well thought-out standard way of doing it (I hoped M-Expressions were ... parse trees in lei of developing an M-expression syntax for production ...
    (comp.lang.lisp)
  • Re: Am I parsing this correctly? (when do I build the symbol table)
    ... language, or try to approximate some other language, and in those ... easier to parse. ... Some designers choose one, some choose ... One design point is reserved words or no reserved words. ...
    (comp.compilers)