freenode/lisp - IRC Chatlog
Search
20:50:43
makomo
ahh, good point i guess. so the first form would be something like (my-macro ... (foo ...) ...)?
20:52:25
phoe
the latter would work fine, the former looks weird because macroexpanders must be idempotent
20:53:16
makomo
during macroexpansion is when my PLACEP would be called, but the setf expansion would be present in the expansion of my-macro somewhere
20:53:43
phoe
looks like a case of "if it ain't broken, don't fix it" simply because the place can be defined after your PLACEP is called
20:54:55
makomo
does sbcl normally generate a warning in such a case? when you're using a function before it's been defined?
20:55:21
phoe
I mean, if you explicitly require that all places must be defined before your macro is expanded, then your PLACEP is going to work and be useful
20:56:13
makomo
speaking of caveats, there's a peculiar thing that i noticed in jensen's device https://en.wikipedia.org/wiki/Jensen%27s_device
20:56:45
phoe
also (progn (defun (setf foo) ...) (my-macro ... (foo ...))) - is this going to work without an EVAL-WHEN around the DEFUN?
20:58:00
makomo
regarding jensen's device: the parameter k that's passed by value is weird, because it's also used within the syntax of the for loop construct to introduce a binding that's not really called k
20:58:45
makomo
or rather, the for loop construct is weird, or maybe just the whole call by name strategy in algol
21:00:09
makomo
i'm aware of the "capture-free substitution (copy) rule" that's used to define call by name, but it's still weird to me that the k gets substituted in that context, because you would think it's part of the for loop's syntax, and not in a place that's to be "evaluated"
21:00:54
phoe
like, FBOUNDP on (setf foo) returns NIL even if DEFUN (SETF FOO) occurs earlier in the same PROGN
22:40:27
copec
I've previously only done math things in CL as a hobby, but I'm trying to interface with Plesk panels that I manage for my work
22:41:53
phoe
the naïve way would be to use emacs with some sorta xml-mode since a schema is just an xml document
22:42:23
phoe
a more involved way would be to try and convert that into s-expressions and/or a nested Lisp object mayhaps
22:44:09
copec
They have them rendered as .svg's but without a legend or anything, I guess I can look at the actual .xsd files and lookup what the tags mean in the branches
22:45:22
copec
I have two initial thoughts on implementation, simple functions that wrap the stream with tags, but it would be neat to figure out a macro to write a defclass hierarchy from the xsd
1:00:43
no-defun-allowed
Indeed. Though I assume you would want to make sure the returned form tests X, as the macro currently tests if the symbol PI is greater than 0.
1:01:50
Alfr
And as for why it doesn't work, macro expansion doesn't evaluate its arguments. Thus you're passing the symbol PI, and then X is bound to it, thus you're trying to evaluate (> 'PI 0).
1:03:17
bmansurov
Thanks both. Assuming I want to make that macro work, how do I pass the constant PI to the macro, rather than the symbol?
1:03:33
no-defun-allowed
If you really wanted to, you may write (defmacro positivep (x) `(if (,x 0) 'yes 'no))
1:05:37
bmansurov
I see. I guess I should share another example where the problem I'm trying to solve is more pronounced. Here it is:
1:06:31
White_Flame
however, in most cases, what you really want is to construct code that the compiler will collapse for you, instead of trying to fiddle stuff at this level
1:08:16
no-defun-allowed
You will have to decide if (> from to) at runtime, perhaps by replicating and generating (if (> from to) (loop ... to ...) (loop ... downto ...)). But this would again be better as a function.
1:08:25
White_Flame
this is a runtime decision you have to make, based on the actual runtime value being passed into a call; this isn't something you can statically resolve
1:09:03
bmansurov
OK, thanks. So there's no way to solve the above problem with macros other than creating two loops?
1:09:51
White_Flame
if you make 2 loops, you'll have a (if (> from to) (loop ...) (loop ..)), and if FROM & TO are numeric literals, the CL compiler should constant collapse one of them away
1:10:49
bmansurov
I went this rabbit hole because I didn't want to write a function with two loops. I appreciate everyone's responses.
1:11:46
White_Flame
even if you special-cased in a test for pi, what would you think ot generate for (seq x y) ?
1:19:34
bmansurov
My biggest gripe with Common Lisp is that at some point I got this macro stuff, but because I didn't practice writing CL, I forgot it. Learning Common Lisp is not like learning to ride a bicycle, unfortunately. I have to relearn this stuff. ;(
1:21:42
bmansurov
I don't know. For me, unlike JavaScript, for example, Common Lisp was hard to learn (even though I already knew how to program). It's even harder to retain that knowledge.
1:26:31
White_Flame
and of course the reason there's upto vs downto is that the exit comparison needs to be <= or >= depending on the direction
1:27:15
bmansurov
Thanks, I appreciate your help. I was more interested in getting ~to~ and ~downto~ working. As others have suggested, and as you have showed, there are many ways to skin this cat. I was after that specific way.