libera/#lisp - IRC Chatlog
Search
16:58:38
mrcom
Lotttts of links to interesting Lisp stuff, such as http://lispm.de/docs/Publications/UI/ which links to Lisp UI papers, e.g. "Allegro CL CLIM 2.2.2 User Guide".
17:00:57
mrcom
Then there's the "Links" page, which includes "IGOR - A microprogrammed LISP machine :: Overview :: OpenCores" at https://opencores.org/projects/igor [lispdm.de site points to old opencores.COM]
17:16:44
mrcom
NOTE: lispm.de home page says 'this is a tiny server' and "don't try to copy the whole site". Sometime between 2022-02-23 and 2022-02-28 he started returning an "Access Forbidden" page to the Wayback machine.
17:17:53
mrcom
So we should probably be careful about posting links on something that would get it hugged to death.
17:24:46
thymage
Where decl is defined by: https://github.com/kiselgra/c-mera/blob/master/src/c/syntax.lisp
17:25:16
thymage
I just would like to take the (decl part off of each list and then slap a single one on at the end.
17:32:43
jackdaniel
if you want to "take the decl part out", then (defvar v3 (decls ((float a) (int c))))
17:33:06
jackdaniel
mixing results of macroexpansion with concatenate won't work the way you desire them to
17:37:17
mrcom
Gotcha. Reason I asked is that it appears DECL is creating a structure which the rest of the C-Mera understands. Don't know how C-Mera expects structs or unions (not clear which is meant) to be declared.
17:38:23
mrcom
(C-Mera is a "source-to-source compiler that utilizes Lisp's marcro system for meta programming of C-like languages."
17:43:48
mrcom
thymage: I think DECL is a macro, not a function, and it is evaluating its arguments.
17:46:23
mrcom
This means it won't be simple to compute arguments to it. `(defvar v3 (concatenate ...)' doesn't compute the concatenation of v1 and v2, and then pass that to DECL.
17:48:28
mrcom
DECL sees, I believe, '(concatenate v1 v2); i.e. a list of three symbols CONCATENATE, V1, and V2.
17:49:33
mrcom
It's going to try to interpret that using it's c-like syntax; CONCATENATE would be a variable name, V1 would be a type, and V2 would be some kind of assignment or modifier.
17:51:58
mrcom
Yes. DECL is a macro; the code it generates returns some kind of internal C-Mera structure which lets the rest of the C-Mera macros know what to do.
17:54:46
jackdaniel
I see what you mean, you refer imaginary form that has never appeared on this channel, like (defvar v3 (decl (concatenate v1 v2)))
17:56:11
thymage
jackdaniel, Well, the whole reason I want to concatenate two lists is because I want to be able to make combinations of decl's
17:58:50
thymage
I was able to get it to run correctly by just putting (struct z v1 v2) instead of concatenating into v3 and doing (struct z v3)
17:58:52
mrcom
The biggest one is that DECL *only applies inside a function declaration. I don't see a way to declare a global (special) variable using c-ish syntax.
18:00:46
mrcom
You trying to globaly declare boilerpate to include in function? E.G., declare common sets of variables to include in a function?
18:05:16
thymage
So, if (struct z v1 v2) works, how can I write a macro around that in order to pass an arbitrary set of things that will get spliced in. So, after my defmacro, it would see the correct sequence if I call (declare-struct (v1 v2))
18:13:15
mrcom
So thyimage: Looks like you will need to create boilerplate which is included whereever you reference the structure.
18:24:19
mrcom
Some macro is going to need to evaluate its arguments. Let's make a general TYPEDEF macro.
18:26:01
thymage
Why are you still going on about typedef. I literally have not looked at and may not ever need typedef. I don't want to typedef.
18:26:55
mrcom
You want to globally declare a type which is then usable inside a (function foo ((MY-GLOBALLY-DEFINED-TYPE x)) ...), right?
18:27:19
thymage
I'm not working on that right now. I want to be able to compute all different kinds of structs using the macro language.
18:28:54
mrcom
Got it. Different combinations. Are you intending to use a particular combination in more than one (function...) block?
18:29:12
thymage
I am not really knowing whether it has to be in any (function. Originally, I thought that the (decl had to be taken off of each variable before their being concatenated and then put back on.
18:30:07
thymage
Mrcom I haven't thought that far ahead. Basically, after generating combinations I will then generate some C functions that use each of the different structs.
18:30:57
mrcom
You want to create a structure type-ish-thingy, and then include that thingy in various functions.
18:34:46
mrcom
Before you get that far, how do you use DECLARE-STRUCT? It appears you need to include it in each (function ...).
18:36:05
thymage
I could have the struct declarations at the C top level. So, I just think the permutation computation needs to be able to pass each possible set of arguments to the declare-struct macro
18:36:38
mrcom
In other words, does this work in C-Mera: "(struct z ((a float) (b int))) (function ((foo (struct z))) ...)"
18:40:15
thymage
And I just want to know how I define the macro correctly so I can compute v3. Please
18:44:12
thymage
I think my question references c-mera because that's what it is in terms of. But maybe it doesn't have to involve that.
18:45:09
thymage
Suppose instead that I just want to know that for a given macro, I can compute any set of arguments. (v1 v2 ... vn)
18:45:36
thymage
But, what it calls should receive that set as that set. So, you can see that (declare-struct (v1 v2)) runs just fine.
18:45:58
mrcom
What you're asking for is known as a macro that accepts a list of arguments and evaluates them.
18:49:35
thymage
This is like my second day of using lisp. I don't like the books that are out there so far.
18:50:52
mrcom
But be warned, macros are one of the more hair-pulling bits of Common Lisp, and macros that evaluate arguments even more so :)
18:55:07
thymage
So, above the macro call I have defvar v1... and so on. And I pass v1 or whatever to the macro
18:59:21
dlowe
if you're emitting code from a macro, why on earth would you use eval? Just emit the code that does what you want!
19:04:29
mrcom
(defvar v1 '(a float)) (defvar v2 '(b int)) (defmacro declare-struct (&rest args) `(struct ,@(mapcar #'eval args)))
19:05:06
pjb
This cannot work: you mare mixing things defined at run-time (the variables) and things that work at compilation-time (the macros).
19:07:54
thymage
Actually, what if I define a macro that returns another macro. And I will just incrementally build the struct until I close it...
19:08:44
mrcom
pbj: Important thing is that it will be evaluated and defined before the following... oh.
19:10:28
mrcom
As pjb pointed out, defvar isn't the right thing; it evaluates at the wrong time, after the (function ...) macros would be processed.
19:10:31
thymage
Oh that was just an example. Whether v3 is supported by defvar or not, that is fine with me, as long as I can pass it to the macro
19:11:04
pjb
and then (my-type-language (define v1 (a float)) (define v2 (b int)) (define v (structure v1 v2)))
19:11:27
pjb
If you wrap all your type expressions inside your type-language macro, you can do whatever you want.
19:16:38
mrcom
thymage: What pjb was reminding me of was the evaluation/compile cycle timing in Common Lisp.
19:16:59
thymage
mrcom, but these aren't constants?? I mean, sure it needs to work with the macro expansion, but v3 will change
19:20:32
thymage
I mean, sure it may compile or it may run. But I'm not doing anything but printing the results.
19:21:16
mrcom
One thing to consider is that each variation of the structure means you'll have a variation in the _function_, too.
19:21:35
thymage
ergh. I'm pretty sure there is a way to compute a list of arguments and splice the list contents so that list l passed to define-struct is seen as define-struct <list contents>
19:22:41
mrcom
So if you're trying something like "for x in int, uint, float, double; for y in float, double; typedef z (a x; b y); function foo (w z)..."
19:22:41
pjb
Things that need to be done at compilation time, like splicing lists of arguments must be done in macros.
19:23:22
thymage
mrcom, that's ok, I'll make the many variations of foo after I get structs all the way down
19:23:29
pjb
(defmacro my-type-language (&body expressions) … (interpret expressions) … (generate-type-expression … argument-list …))
19:24:38
pjb
As long as those regular functions are defined in the compilation environment, using either eval-when :compile-toplevel, or by putting them in separate files compiled and loaded before your compile the files defining and using the macro.
19:25:19
pjb
`(declare-struct ,@(list 'v1 'v2)) --> (declare-struct v1 v2) then why don't you just write: (declare-struct v1 v2) ???
19:26:21
mrcom
pbj: From what I can tell, it establishes a compile-time context using a FUNCTION macro (yeah, wonderful name collision).
19:26:54
mrcom
FUNCTION is like LOOP. It evaluates its argument s-expressions and spits out C code as a result.
19:28:11
mrcom
The s-expression syntax and semantics are already determined. He's trying to spoon-feed it some global type definitions.
19:38:22
mrcom
thymage: It's using something called reader macros. These happen even before compile-time, and before DEFCONSTANT computes its value.
19:48:37
mrcom
If defining an outside macro is ok, then we should be the equivalent of (function foo () -> int (decl ((y int = 0))) (return y)))
19:50:59
mrcom
Oh. Just saw that the c-mera reader is optional for prototyping, and switch back to cl-reader. That sounds like good news!