freenode/#lisp - IRC Chatlog
Search
1:56:33
stacksmith
I think it's useful. Anyway, I just did it. I don't ever want to look at this code again, and I can imagine a with-macro in another package situation... My idea of always using local bindings sucked - with :old you use existing bindings which could well be in another packege...
6:03:31
Godel[m]
Hi, I'm trying to use read time evaluation macro `#.` with a function which is in the same file as the function call and get error that the called function is undefined (at read time). Is there any way to resolve this without splitting them in two separate files and compiling one before the other? Is there a way to force compilation of a function/sexp before read time evaluation takes place? An example of the scenario:
6:03:31
Godel[m]
https://bin.disroot.org/?316c523091169696#7Ir1LoUETE0dpC7Y8GVC7mgRYXomirC1YJN4rmnyZn4=
6:05:36
no-defun-allowed
Maybe load-time-value would be more appropriate, then remember to wrap FACTORIAL in an (eval-when (:compile-toplevel :load-toplevel :execute) ...) form
6:06:07
no-defun-allowed
Though, when loading or compiling a file, it's done one form at a time, right? Then the LTV wouldn't be needed.
6:59:18
beach
(FLET ((FUN (...) ...)) ...) is basically the same as (LET ((FUN (LAMBDA (...) ...)) ) ...) except that in the first case, FUN is in the function namespace, and in the second case, it is in the variable namespace.
7:10:32
beach
fragamus: Sure, a macros is just a function that takes a form and returns another form.
7:11:30
beach
fragamus: But your question is ambiguous. Do you mean that another macro is defined DURING THE EXPANSION of the first one, or BY THE EXPANDED FORM?
7:12:23
beach
fragamus: You typically don't want to do that. It is best if macro functions are side-effect free.
7:14:01
LdBeth
Usually there is a staging limitation, the reason is obvious: you cannot can a function not yet loaded into the environment
7:17:17
fragamus
once macro code gets generated dynamically, and some lisp code is generated also which refers to the new macro, then that is part of the expansion
7:19:12
LdBeth
If you’d like to make all the things “static” that’s not trivial. Although not completely impossible.
7:20:19
beach
fragamus: I agree with LdBeth. In Common Lisp, a macro definition (by DEFMACRO) is turned into a macro function that is compiled after the DEFMACRO form has been expanded.
7:21:05
beach
fragamus: When a macro call is encountered by the compiler, the compiler executes the macro function to obtain an expansion, and then compiles the expanded form instead.
7:22:56
beach
Yes, and there is no "dynamic" compilation of the macro definition. It is done once when the macro definition is encountered.
7:23:24
beach
fragamus: In fact, DEFMACRO is itself a macro that expands to something like (setf (macro-function ...) (lambda (form environment) ...))
7:25:07
beach
That is kind of implied by the fact that it compiles the expanded form in place of the macro form. It doesn't treat the expanded form any differently from other forms.
7:26:24
beach
So you start by writing yourself a Lisp system that is not an implementation of Common Lisp?
7:30:00
LdBeth
Or maybe you could lookup hygienic macro or other meta programming technology, even call by need evaluation that does some sort similar thing to macros
7:33:16
Godel[m]
About the read time evaluation macro, if the result of evaluation is a struct, sbcl says it doesn't know how to dump a struct (I'm not dumping a runtime image though). Is there a way to tell it how to dump it? Or is there a list of types it knows how to dump?
7:35:28
LdBeth
Göd.el: it’s a little hard to comprehend but you can search some tutorial thing about it
7:36:30
fragamus
sometimes people don't get why syntactic sugar causes problems. I need compelling reasoning to drive the point home
7:37:09
aeth
syntactic sugar is great, I just don't want to wait until the next version of the language to get it (and in the case of CL, that would be quite the wait!)
7:37:37
beach
fragamus: Are you trying to convince someone else to use Lisp? It is nearly impossible to convince people, because there are very strong psychological forces involved.
7:38:08
LdBeth
fragamus: it usually means the reader of your code have to spend extra time to understand how those syntax works if you didn’t design these properly or these are not well documented
7:38:53
beach
fragamus: No. It happens to very smart people too. Carol Dweck calls it a "fixed mindset". She has some good talk available on YouTube.
7:40:12
LdBeth
In the meantime, if that’s a well recognized thing (in the domain of problems you want to solve) that haven’t been introduced into the programming language, that should work reasonably fine
7:40:18
aeth
It takes a lot of time to master a programming language, which is a time investment people don't want to repeat, even if it's faster the more you do it.
7:40:59
ck_
I have less trouble understanding the absence of popularity of lisp than the popularity of other languages, like Java for example
7:43:36
jackdaniel
some people criticize lisp for being to easy to work with, as in: it is easier to wrap "scratch-my-itch" hack than to contribute to existing solution
7:44:49
ck_
yes, exactly. I once attended a talk about "finding a good cond-let library" (for clojure)
7:45:04
jackdaniel
if I had to play devil's advocate I'd say, that I'd prefer one complete library after 5y than 100 incomplete libraries in a week
7:45:08
ck_
baffling. There's probably three dozen cond-let macros people have whipped up in half an hour around
7:46:02
ck_
Well it's not like lisp is all impromptu and no planning. The (Hyper)spec is a great achievement.
7:46:10
no-defun-allowed
(defmacro if-let ((variable value) then else) `(let ((,variable ,value)) (if ,variable ,then ,else))) ; three dozen and one
7:48:51
fragamus
jackdaniel: just remember when you play devil's advocate, you are merely saying what satan would say
7:49:31
jackdaniel
well, I like Common Lisp and I work with it a lot, but this language has serious flaws neverless, so I'm far from calling it panacea (and shy away from comparing with other languages)
7:50:24
jackdaniel
because such criticism would be very flawed unless I'm expert in *both* languages
7:50:55
jackdaniel
I can compare CL with C: both languages are different, have different purpose and are incomparable
7:52:29
ck_
Okay I disagree somewhat. Of course different languages have different paradigms and a direct comparison is not always fruitful. But to say you shouldn't compare anything at all between languages is throwing out the contents with the bathwater
7:53:16
jackdaniel
no, I'm just saying that it is too often seen that people compare A to B where they know only A in fact
7:54:34
aeth
jackdaniel: I think the library issue is just because of who's making the libraries for CL. Almost entirely amateur projects.
7:55:38
fragamus
I think non-lisp languages require one to inhale the syntax in order to properly step over it when meta-programming
7:59:36
LdBeth
Since there’s a lot of string rewrite based languages before or near when lisp invented
8:08:46
Godel[m]
LdBeth: Looks like SBCL does know how to dump structures without needing make-load-form iff the struct definition is evaluated before the call to dump it. I hadn't put the struct definition in eval-when.
9:51:40
Godel[m]
I just noticed, upon putting defuns inside `(eval-when (:compile-toplevel :load-toplevel :execute) ... )`, CCL doesn't compile those functions, and I get `Undefined Function` errors. SBCL works fine.
9:53:56
Godel[m]
(I mean, I get the errors from the toplevel (sly) not when I call them inside the file.)
9:55:48
beach
Godel[m]: The standard allows for the compilation environment to be different from the startup environment.
9:56:30
beach
So it is possible that CCL defines the function in the compilation environment and then discards that environment once the compilation is done.
9:58:12
beach
Because compiling a file should not have any side effects on the run-time environment.
9:59:34
Godel[m]
I have an asdf package, I compile it and switch to the package, should I expect the symbols in it to be loaded after compilation of all the files?
10:00:41
beach
OK, let's try some correct terminology. I take it you have an ASDF *system* (not a package), right?
10:02:44
beach
When the compiled files in the system are loaded, you will see all the side effects of all the top-level forms in the files.
10:03:41
beach
So the effect should be very closed to the effect you get if you LOAD all the source files.
10:08:49
beach
Any symbol without a package marker, or with an explicit package marker in any of the files will typically exist.
10:13:40
beach
Not sure about names of lexical variables in a system where the packages are created only in the compilation environment.
10:18:32
beach
Names of lexical variables that are not otherwise needed in the compiled code (like, say, for debugging purposes) are not necessarily present after the system has been loaded.
10:20:00
beach
Example: Put this in a file: (defun ff (xxx) (1+ xxx)) or something like that. Start SLIME. Type (proclaim '(optimize (debug 0) (speed 3))) and then (compile-file <name-of-lisp-file>).
10:20:30
beach
This is SBCL I am trying now, so now, restart your Common Lisp system by typing ,restart or something like that.
10:22:40
beach
However, since SBCL does not distinguish between the compilation environment and the startup environment, if you stay inside your running SBCL system, compiling the file will create the symbol XXX, simply because the file is being read by READ.
10:47:32
Godel[m]
Actually, that's not what happens for me in case of sbcl 1.5.4. I compiled a file (test.lisp) with a factorial function, and load it with `--load test.fasl`, then when I evaluate `(find-symbol "FACT"), FACT is returned, an internal symbol. Contents of the test file: https://bin.disroot.org/?6b6ddb183282a081#L4vdMR3Q+IgLCcikl6+2uZpBq1g5xtkIzaF0q8Dtk8k=
10:55:16
ck_
but your discussion was about arguments to the function, not the function name ?! I'm confused. Of course the function symbol will be part of the fasl
11:02:33
Godel[m]
yes, I started a different session in the terminal with 'ros run --load test.fasl`.
11:21:08
ck_
hmm, you are right, that's what my sbcl does as well. I have not used slime for this either -- maybe there are some different settings in that environment?
11:25:58
ck_
or -- the ever-present forces of darkness have prevented you from removing superfluous symbols at this time
11:28:21
Godel[m]
Okay, that aside, how do I tell CCL to load the symbols in the startup environment?
11:29:58
no-defun-allowed
DEFPACKAGE will create the symbols when it creates the package too (to my knowledge).
11:48:31
Godel[m]
Well, I'm stupid. My init file for quicklisp had a form dependent on sb-ext which prevented it from loading anything other than the forms before that non-conforming form with CCL. Would have been easier if roswell's sbcl just used `.sbclrc` instead of roswell forcing the same init file on all implementations.