Pascal J. Bourguignon <pjb@informatimago.com> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) writes:
| > Pascal Bourguignon <pjb@informatimago.com> wrote:
| > +---------------
| > | But this is only the lowest level of that system.
| > | (You could call it "CLAP", for "C Level Assembler Program").
| > +---------------
| >
| > Well, being a networking/datacomms kind of guy myself, I tend to
| > call it "LAP-C". [There's a bad pun in there for old datacomm types].
| > But, yes. That's exactly what I'm looking for. Are you willing to
| > share your surface syntax/notation? Or at least its general shape?
...
| > ... [just] trying to get a leg up by learning from others'
| > mistakes without having to re-make all of them myself! ;-}
...
| (cl:in-package :c)
|
| (comment "Here is a little function")
|
| (define-function string_add ((a string_t) (b string_t)) string_t
| (let ((av int)
| (bv int)
| (res string_t (malloc (+ 2 (max (strlen a) (strlen b))))))
| (sscanf a "%d" (address av))
| (sscanf b "%d" (address bv))
| (sprintf res "%d" (+ a b))
| (return res)))
...
| /*
| Here is a little function
| */
| string_t string_add(string_t a,string_t b){
| {
| int av;
| int bv;
| string_t res=malloc(2+max(strlen(a),strlen(b)));
|
| sscanf(a,"%d",&av);
| sscanf(b,"%d",&bv);
| sprintf(res,"%d",a+b);
| return(res);
| }
| }
+---------------
Thanks! That helps a lot.
+---------------
| Unfortunately, my code is not ready for public consumption yet.
+---------------
Not a problem. As I said, I was just looking for the general shape
of your s-expr syntax, which your examples handily provided. Your
DEFUN & LET syntax is "flatter" than the one I was considering,
and looks better, that is:
(let ((var type [initializer])) ...)
instead of:
(let (((var type) [initializer])) ...)
And:
(define-function func ((arg type) (arg type)...) result_t
...body...)
instead of:
(c-defun (func result_t) ((arg type) (arg type)...)
...body...)
Those were just the sort of suggestions I was looking for, thanks!
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607