freenode/#lisp - IRC Chatlog
Search
23:10:37
jeosol
fiddlerwoaroof: I forget to mention that the evaluation I am trying to do is inside another macro -- i get your point about this being nasty
23:18:51
White_Flame
jeosol: if you want the value at compile-time, then that's likely wrong, unless you're absolutely certain that the property has been set before compiletime
23:20:30
White_Flame
if you want the value at runtime, as above you're still macroexpanding to the symbol to allow that to be evaluated at runtime, so nothing changes if it's 1 macro, a macro that uses another macro in its output, or a macro that needs another macro's expansion at compile-time
23:26:50
jeosol
White_Flame: no, it's not compile time. I think symbol-value did the trick - I wanted to understand how to do it for one case. It's one macro per se but I am trying to paste the correct variable values during the macroexpanding.
23:33:27
phantomics
Like I have a function used within a macro to generate code, and that function can take a pathname as one of its parameters
23:34:28
phantomics
But it could either be a literal pathname, like #P"/tmp/stuff.txt" or a pathname generated by code like (pathname (format nil "~a/stuff.txt" "/tmp"))
23:35:02
phantomics
The function used within the macro will just receive '(pathname (format nil "~a/stuff.txt" "/tmp")) if that's what gets passed to the macro
23:35:45
jeosol
fiddlerwoaroof, White_Flame: my chrome crapped up, not sure last message got through, but thanks for your brainstorming
23:35:53
White_Flame
of course, if it receives (pathname (format nil "~a/stuff.txt" my-dir)) with my-dir as a lexical variable,it wouldn't work
23:37:10
phantomics
Yeah, that's a shortcoming, so literals are always preferred in a case like that
23:38:01
Xach
phantomics: one common option is to put the code that produces the value you want into the expansion, rather than trying to compute the result at macroexpansion time, defer it to runtime.
23:38:27
White_Flame
but if you're generating code from that .txt file, then you'd just be deferring the EVAL until later
23:38:45
White_Flame
either EVAL the filename, or EVAL the expansion of the contents; the former is probably safer
23:38:46
jeosol
I was saying I was doing have two-levels of the indirection (creating the variable from string and using the value from that variable again ...)
23:38:48
phantomics
Yeah, this is for the April APL compiler, the contents of the file would be the code it's going to compile
23:39:24
jeosol
maybe mine is a bad design, I am trying to construct and paste variable names in the macro and when its run, those variables will have values
23:41:00
White_Flame
and the fun thing that most people have to have an "aha!" moment with is that the value usually doesn't even _exist_ when the macroexpansion code is run ;)
23:41:21
jeosol
The refactoring I did has simplified the interface greatly and pushing a lot of the functionality later.
1:19:44
save-lisp-or-die
there's a cool use for when you want to stack allocate a value http://www.sbcl.org/manual/#Dynamic_002dextent-allocation for efficiency reasons.
1:23:52
save-lisp-or-die
So if you're consing a tonne of memory in a hot loop that the garbage collector is hiccuping to free, stack allocation might be useful there.
1:31:16
no-defun-allowed
Well, allocation with a moving GC is almost comparable to stack allocation. It's sometimes useful, but I don't bother with dynamic-extent.
1:32:54
save-lisp-or-die
does ECL respect it? I could see maybe on resource constrained devices it might be useful.
1:35:08
no-defun-allowed
I am not sure if ECL is the right implementation with small resources; don't you either need a C99 compiler or bytecode interpreting?
1:37:52
no-defun-allowed
Also, see "Garbage collection can be faster than stack allocation" <ftp://ftp.cs.princeton.edu/reports/1986/045.pdf>. That should be read with heavy emphasis on "can".
1:37:59
mfiano
Additionally, implementations need only to honor NOTINLINE, and SPECIAL declarations, and conform to the safety rules for OPTIMIZE
1:39:16
no-defun-allowed
If you can free enough in one GC cycle, it eventually becomes faster to not un-bump the stack pointer.
1:40:08
no-defun-allowed
But really, the memory overhead for that to happen is ridiculous. The moral of the story is everthing is a time-space-sanity tradeoff.
1:40:57
no-defun-allowed
(And Firefox crashed after sending that. I'm not one for conspiracy theories though.)
1:41:52
no-defun-allowed
The SPECIAL declaration means that variable will use dynamic binding, instead of lexical (like you usually expect, and is default in Common Lisp). I usually prefer to write (defvar *foo*) to make *foo* a special variable though.
1:44:59
no-defun-allowed
Usually people write a program like this to demonstrate: (let ((x 3)) (defun g () x)) (defun f () (let ((x 2)) (g)))
1:45:21
no-defun-allowed
If X is lexically bound, then (F) returns 3. If X is dynamically bound, it returns 2.
1:49:09
no-defun-allowed
Dynamic binding will give you the last value bound, no matter where it's bound; and lexical binding will give you the last binding you can see where the variable is used.
1:50:18
no-defun-allowed
For example, *standard-output* is a special variable. If I evaluate (with-output-to-string (*standard-output*) (room)), it will be bound to the string output stream WITH-OUTPUT-TO-STRING makes, and ROOM will write to that.
1:52:30
lotuseater
or if you do something like (let ((*print-base* 16)) ...) or (let ((*gensym-counter* 1)) ...)
4:09:18
phantomics
A question about SICL: what kind of support will it have for ASM generation? Anything like define-vop in SBCL?
4:10:40
beach
phantomics: Since all the stages are programmable, it should be possible to customize at will.
4:10:57
phantomics
Lets you implement functions in assembly: https://pvk.ca/Blog/2014/08/16/how-to-define-new-intrinsics-in-sbcl/
4:13:21
phantomics
I'm looking into it to optimize my project; unfortunately, it will only work under SBCL and there's no ASM generation faculty that works across implementations
4:13:43
beach
phantomics: I have not thought of a similar way in SICL. However, since code generation is done with generic functions that take a CLIENT object that can be specialized to, then code generation is very easy to customize.
4:14:35
beach
phantomics: It is also easy to define new IR instruction classes, new AST classes, and new primitive operations (primops) to use at the source level. I do that all the time.
4:18:42
beach
Since SICL uses the Cleavir compiler framework, and Cleavir was designed to be implementation independent, we designed it from the start to be extremely flexible and adaptable to different implementations.
4:20:22
beach
But I haven't given enough thought to a consistent protocol for tweaking code generation within an implementation.
4:37:15
phantomics
You can see a lot of define-vop examples in this directory: https://github.com/sbcl/sbcl/tree/master/src/compiler/x86-64
4:38:27
phantomics
You can see optimized functions for handling arithmetic, arrays, etc. It's the x86-64 specific stuff, in the neighboring directories you can see implementations for ARM, Power, RISC-V, etc.
4:40:18
pillton
I need help figuring out the noun for something. Assume X is an instance of the class C. (apply #'F X args) returns Y and (funcall (apply #'F C args) X) returns Y. Is there a noun which describes the function F?
4:41:38
pillton
The closest thing I have found is lazy evaluation but I am not sure if that is correct.
4:44:29
beach
The function F is a bit strange since it can take arguments of different "meta" levels.
4:45:15
pillton
Knowledge of the class C is important. I was wondering if Cleavir would be useful for optimising the graph generated by successive compositions e.g. (funcall (optimize-computation (apply #'G (apply #'F C args) args2))).
4:48:16
pillton
No worries. I have lost track of the time and I need to pick up kids. I'll be back in a bit.
4:48:55
lotuseater
speaking of currying and nouns, did you know, another noun for it is Schönfinkeln :)
5:54:44
janislago
but im doing this just for clarity and to give myself a readily identifiable name i suppose
5:59:54
beach
You should know that #lisp is fairly strict with staying on topic. There is #lispcafe for idle chatting.
6:00:25
janislago
was just about to mention that emacs lisp is a little weird when youre adjusted to cl
6:04:39
beach
janislago: You need to be a little bit careful with that approach. Common Lisp has several implementations that behave differently, and lots of behavior is unspecified by the standard, so you may accidentally produce non-conforming code without knowing it.
6:09:05
janislago
could you relay to them that on windows 7 and probably later versions, there is an error with attempting to access files via (load) where an error signals for "the operation completed successfully." this occurs both when running as admin and running as a normal user
6:11:06
janislago
yeah its not my first choice for programming but win7 runs incredibly well even in 2020
10:41:55
beach
Wow, that was a scary bug. In SBCL I did (make-instance 'standard-generic-function :lambda-list '(x)) and initialize-instance signaled an error that the value of the :METHOD-COMBINATION initialization argument had to be a method-combination object, but that instead it was... the STANDARD method-combination object. Restarting SBCL made the problem go away.
10:43:42
beach
The combination of bugs like this (SBCL or my code, doesn't matter much) and inadequate tools for finding the problems makes the task of development less pleasant than it could be, and certainly way more time consuming.
10:50:13
ck_
Were these types of one-off mystery bugs always around like that, or do you think these situations have become more frequent?
10:52:28
ck_
Increased project size that comes with more powerful environments and more people with access to them might be a conceivable reason
10:53:23
beach
Sure. I have no hard evidence that it is a problem with SBCL. But I couldn't guess what I could have done myself to make it happen.
10:54:16
beach
My favorite reason is to blame too complex code, due to many decades of modifications.