libera/#commonlisp - IRC Chatlog
Search
10:46:43
VincentVega
So, in a situation like this https://pastebin.com/Ft6qYNMa , what can I do to optimize away the WHEN clause? Any way to declare FLAG constant?
10:48:13
phoe
that's slightly subpar because it leads to code duplication, but you do seem to want code duplication - you want to return different functions depending on the value of flag
10:49:17
phoe
but, good golly, I hope you don't use microoptimizations like these for simple functions like that
10:49:49
phoe
VincentVega: not really; you basically want to return different anonymous functions based on the value of FLAG
10:50:16
phoe
and LAMBDA is not a good abstraction for that, because it always describes a single body of code
10:51:30
phoe
you can only try to hide it behind some sort of macrology, but adding conditionals like that would likely require code walking in order to find the conditionals in the code
10:52:21
phoe
like, if a hypothetical FLAG-LAMBDA like (flag-lambda (x y z) ...) expands into conditionals based on X, Y and Z, then (flag-lambda (x y z) (... (... (flag-when x ...))))
10:52:46
phoe
this requires code walking so FLAG-LAMBDA can recognize how to skip or not skip the inner FLAG-WHEN invocation
10:53:33
VincentVega
phoe: Hmm, I see what you are saying, that makes sense. But to avoid code walking, I could write a seperate macro too, so that's cool. Well, thanks for explaining this!
10:55:14
Nilby
I don't think you need walking if you don't care that there's two versions of the lambda
10:55:43
phoe
Nilby: I mean, one of these lambdas needs to have the PRINT call and the other needs to not have it
10:56:44
phoe
so something like (flag-lambda (x) (flag-when x (print "foo")) (+ 1 2)) expands into (if x (lambda () (print ...) ...) (lambda () ...))
10:57:14
phoe
and I just realized that you can avoid code walking - you can pass information in &environment
10:57:47
phoe
and it will cause FLAG-WHEN to expand into either (progn) for nothing or (progn ...) - depending on whether a given flag is meant to be set for the given generated lambda
10:58:30
phoe
VincentVega: I can sketch out a solution later today if you're interested and/or don't know how to start
10:59:07
VincentVega
phoe: I think I know what you are saying, I am playing around with code rn to see what works best : )
11:12:44
VincentVega
I mean, the other way is to do this generally like phoe suggested. For multiple variables, that is, would be useful. Maybe I will even make it.
11:31:56
VincentVega
phoe: Nilby: OK, it's actually quite nifty with a symbol-macrolet https://pastebin.com/WN3NU68j except for the deleting unreachable code warnings.
11:42:49
phoe
give me a few hours to finish work and then I'll be able to show you if no one does before me :D
11:46:09
Nilby
Nice. Nearly zero run cost conditional logging. Probably less code bloat than C++ templates. I'm curious to see phoe's extra fancy way.
11:47:52
VincentVega
Nilby: yep, with a custom when-flag, the warnings are gone, will be curious to see another way too : )
13:35:14
phoe
I use &environment to communicate between the outer macro(s) FLAG-LAMBDA and the inner macro(s) FLAG-WHEN
13:35:58
phoe
SYMBOL-MACROLET is a way of writing stuff into the compilation environment and MACROEXPAND-1 with a symbol is a way of reading it
13:36:33
phoe
in the fully macroexpanded code, you can ignore L29 completely - it's just noise leftover by the communication
13:37:18
phoe
what matters is the fact that the (IF X (LAMBDA ...) (LAMBDA ...)) structure is what you seem to want, and a total of 2^n functions will be generated based on the combination of flags
13:38:22
phoe
a tidbit is my use of LOCALLY instead of PROGN to permit declarations, since you have a lot of #.*burn-baby-burn* style of declarations
14:42:45
phoe
and the other being symbol macros whose only purpose is to exist in &env as a way of passing information deeper into the macroexpansion process
14:49:59
phoe
VincentVega: in your previous example, you could substitute SYMBOL-MACROLET for LET and it would still work
14:50:58
phoe
in your previous example, you had (when x ...) turn into (when t ...) or (when nil ...) which generated unreachable code warnings
14:51:22
phoe
now the macro simply doesn't generate any code for the cases that could previously generate something like (when nil ...)
15:10:24
VincentVega
phoe: I take it you wouldn't mind if I use this stuff in my code (under lgpl) quoting you as the author?
16:17:44
phoe
(oh, and don't export the %TRUE-FLAGS% symbol - it's important that users don't have the ability to shadow it in any way)
16:34:46
phoe
Guest746: it's one of the basic uses - ensuring that MACROEXPAND-1 can expand locally defined macros
16:35:17
phoe
otherwise your macros that need to expand other macros will break when MACROLET and SYMBOL-MACROLET come into play
16:42:15
Guest746
yeah i haven't run into any nested macro opportunities yet. I suspect it's in the future for my binary reader/writer so i'll try and keep this stuff in mind.
16:51:25
phantomics
April has progressed a lot, I'm checking off the final todos before a new release, been testing it with all different CLs
16:52:35
phantomics
I just discovered that Allegro CL apparently doesn't know what "alphanumeric" means - try (alphanumericp #\←) and observe the results
16:55:07
phantomics
It seems that in Allegro, (alphanumericp) gives nil for the common keyboard symbols that aren't alphanumeric like +, / and @ but many other unicode characters not on the keyboard will return T
17:04:44
phantomics
You can find the matching characters in an implementation with (loop :for i :below (expt 2 16) :when (and (code-char i) (alphanumericp (code-char i))) :do (princ (code-char i)))
17:06:09
phantomics
Meanwhile in Allegro, all sorts of weird stuff matches, beware though as it may crash your Emacs
17:48:20
phoe
and then call FUNCTION-INFORMATION with the function name plus a lexenv if you have it
17:52:58
CodeBitCookie[m]
so I want to send keyboard and mouse input automatically with Common Lisp. Is there any way you suggest that I go about this?
17:52:58
CodeBitCookie[m]
I would prefer if there were a cross platform solution but if the library depends on Xorg or Windows only stuff then that's fine too.
17:55:28
jackdaniel
Guest746: cltl2 defines the environment access api that contains necessary information
17:55:40
jackdaniel
this information was dropped in the final ansi standard, but some implementations still implement it
17:56:53
Guest746
so no trivial-cltl2? I'm not sure it's a big deal since I can't find local-sockets anywhere besides the same ones.
17:58:58
Guest746
this is for a probably bad idea to autogenerate dbus interfaces if ftypes are declared.
18:02:34
Guest746
well it doesn't help to generate a dbus interface if you don't have a socket to communicate with :)
18:04:21
Bike
isn't there a dbus library that can automatically generate an api from the dbus introspection stuff?
18:08:29
Guest746
well, i'll have to look at that. thanks. Though it seems to generate from introspected stuff, which is the other half. I'm thinking about the part of generating from lisp functions.
18:56:19
jcowan
fwiw, Interlisp has two structure editors built-in, one TTY and one GUI; most Interlisp programming is done in the GUI (one function at a time, as in Smalltalk)
20:57:51
theothornhill
I didn't find any frameworks for using GraphQL in common lisp, so I made one. It isn't done yet, but it works. It follows the spec closely, and aims to be fully compliant when I'm done. However, I'd love to get feedback so that I can improve things before the apis settle too hard. So, shamefully posting it here. Sorry if it is the wrong forum :)