@ramin_hal9001
#ecl #commonLisp is like this:

(defun foo ()
(let ((my-int 0))
(declare (:int my-int))
(ffi:c-progn (my-int)
"int *x;"
"for (x = &#0;*x<5;)" (incf my-int)
(format t "~d" my-int))
my-int))

must go through COMPILE-FILE.

@ramin_hal9001 the (c-progn (thing1 thing2 thing3)) are written as #0, #1, #2 in the C/C++ and by their variables names in lisp, and must be declared as a type ecl's sffi knows about. If libecl was compiled with a C++ compiler, c-progn does C++, if C, it does that C.

@ramin_hal9001 in case this was not ostentatious enough, a small variation:

(defun foo% ()
(let ((my-int 0))
(declare (:int my-int))
(ffi:c-progn (my-int)
"int *x;"
"for (x = &#0;*x<5; (" (incf my-int) "))" ";"
(format t "~d" my-int))
my-int))

The extra "(" ")" is necessary because of operator priority I guess.

@screwlisp @ramin_hal9001

This reminds me of HTML/PL, my self-created programming language that uses HTML tags and self-modification as an alternative to JavaScript...

@wakame @screwlisp the way it can paste C++ code right into the file it emits reminds me of is the C preprocessor, if it were a Lisp. It is like the inventor of ECL thought, “I’ll invent a better C preprocessor that is actually a Lisp,” and then eventually decided to make it conform to the Common Lisp specification.

@ramin_hal9001
@jackdaniel how do you normally describe ECL's mechanism using the system C / C++ compiler?

@wakame

Is that the good old `#asm' pragma in Halloween costume?

Did they really declare a keyword as a declaration?
And how is `unsigned long long' represented?

@screwlisp @ramin_hal9001

@vnikolov
well there's :uint64-t .
https://ecl.common-lisp.dev/static/files/manual/current-manual/Foreign-Function-Interface.html#Primitive-Types

This is a little misleading because ecl's static FFI, which generates C/C++ code and compiles it using the system's compiler. So it is less insane than you think.

@ramin_hal9001

Foreign Function Interface (ECL Manual)

Foreign Function Interface (ECL Manual)

@screwlisp

Thank you.
I have the nagging feeling that it isn't absolutely, positively portable to use `unsigned long long' and `uint64_t' interchangeably, now and forever, but I Am Not A Language Lawyer (IANALL™) and that is off off topic anyway.

I am sure that the implementation at hand that takes care of such embedding of C or C++ fragments is completely sane.
I replied from the user's perspective, but aesthetics is in the eyes of the programmer, of course.

#CommonLisp
#ECL
#EmbeddedC
#NumericTypeNamesInC

@ramin_hal9001