libera/#commonlisp - IRC Chatlog
Search
17:57:19
sveit_
if i'm using symbols as flags inside of a function, is there a reason to prefer keyword, uninterned, or "normal" symbols?
17:58:22
White_Flame
also, even if they're purely internally used within your function, keywords can higlight in your source code and have a good visual distinction from your local var names
17:58:23
sveit_
say that they are meant to be used exactly in the scope of the function body (otherwise I guess uninterned would not work)
17:59:49
sveit_
something like (lambda (x) (let ((size (cond ((> x 7) 'big) ((< x 3) 'small) (t 'unknown)))) (when (eql x 'big) "wow")))
18:01:34
White_Flame
but I could sort of see if you have a ton of potential symbols that you're using to organize it
18:06:29
sveit_
in reality, i have a slightly more non-trivial usecase: i have a relatively small (5) number of numbers in some numerical algorithm, a b c d e, and want to know their relative ordering to decide on the order other parts of the algorithm will run. the most reasonable thing seemed to be to do something like (sort (list (cons 'a a) (cons 'b b) ...) #'< :key #'cdr), which inspired this question
18:07:15
sveit_
i could write some forest of conditionals, but this seemed like a more reasonable approach. if you have a better solution actually i'd really like to see it
18:23:46
White_Flame
the symbols allow you to convert it all to runtime data & manipulate it with SORT, which is reasonable
18:57:32
sveit_
is there a way to put multiple loop statements under a conditional clause? I mean something like (loop for j from 0 below 10 when (evenp j) { collect j into numbers collect (floor j 2) into halves } finally (return (values numbers halves)))
18:57:58
sveit_
where the braces are of course a fake syntax, but indicate when I would like the collections to run
19:51:20
phoe
"The consequences are undefined if the lexical environment surrounding the function to be compiled contains any bindings other than those for macros, symbol macros, or declarations."
20:01:42
rotateq
i had a read on STRING= after it came up some hours ago and "equal call string= if both args are of type string"
20:09:32
phoe
Bike: what's a good way around that? is (let* ((x 42) (closure (lambda () x))) (compile nil closure)) any more non-UB?
20:11:30
phoe
and I wonder which commonly used implementations don't do the "right" thing in this case
20:13:50
_death
there's also the issue relevant to it: COMPILE-ARGUMENT-PROBLEMS-AGAIN.. and COMPILE-ARGUMENT-PROBLEMS before that (mentioned in https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node224.html )
20:14:49
Bike
"The consequences of calling compile on a function that is already compiled are unspecified." yeesh, that's perverse
20:16:09
phoe
"If the definition is already a compiled function, compile either produces that function itself (i.e., is an identity operation) or an equivalent function."
20:20:27
Bike
there's also ENCLOSE in cltl2, which lets you explicitly provide the (still macro stuff only) environment to evaluate a lambda expression in
20:33:43
Bike
hmm. not sure there's anything mandating it be a compiled-function, though in practice it will be. and it's also mandated that it be at least minimally compiled regardless
20:44:38
Bike
the observable effect of compilation is the minimal compilation requirements, and that would have to apply to the inner function
20:53:29
Guest95
SBCL is signaling a UNDEFINED-FUNCTION condition when I try to load my system with QUICKLISP:QUICKLOAD. The reason is because I use the function before it is defined in the file and I can fix the problem by moving the function definition above its invocation. I am confused about this though because I thought that you could use a function before you
20:57:17
phoe
the compiler needs to be able to call a function in order to initialize a global variable
20:58:34
phoe
whereas (defun bar () (foo)) or, alternatively, (lambda () (foo)), doesn't require that
23:46:39
etimmons
yottabyte: there are several versions of arrows out there. I think that one you linked might be the one with licensing issues
2:01:33
yottabyte
In slime, the current directory is set to whatever buffer I started slime in. As I open new files in different directories, slime remains open and still pointed to that other directory, even if I close the original file. How do I change it to the current file's directory? Close and restart slime?
2:06:29
sveit_
in SBCL, would (labels ((f (x) (+ x 1)) (g (x) (+ (f x) 1))) (declare (inline f g)) (g x)) inline the definitions of /both/ g and f into the call?
2:06:49
sveit_
and if i instead put (declare (inline f)) (without g) would f be inlined into the definition of g?
2:33:11
sveit_
thanks! another question: is there a simple way to make macros "fall back", in the sense that (macrolet ((a (b) (if (eq b 'b) ''nice ''not-nice))) (macrolet ((a (b) (if (eq b 'a) 'nicest (SOMEHOW EXPAND A)))) (a 'b))) macroexpands to 'nice?
2:34:56
sveit_
well actually (a b) would work, but by accident. had i called the argument to a, c, it would not work
2:51:20
_death
not sure if there's a standard way.. a non-portable one is (macrolet ((a (b) (if (eq b 'b) ''nice ''not-nice))) (macrolet ((a (c &environment env) (if (eq c 'a) ''nicest (macroexpand `(a ,c) (sb-c::lexenv-parent env))))) (a b)))