freenode/#lisp - IRC Chatlog
Search
23:13:51
borei
trying to find more or less detailed documentation on VOPs, but failed. Only couple articles. Any hint is more then welcome
2:35:43
White_Flame
although that's equivalent to (+ 3 3), so having a function there that's called doesn't make a lot of sense
2:37:58
White_Flame
asarch: you can either evaluated (defun foo ...) right in the REPL, or you could edit a source code file by inserting that DEFUN with emacs/SLIME and load it in. Both methods will immediately have your function available to call.
2:38:51
White_Flame
and you don't need to type in uppercase. The reader auto-upcases text internally when reading symbols
2:39:29
White_Flame
there's also the #clnoobs channel, which might be more appropriate for this level of question
2:42:58
White_Flame
you can just do a plain (let ((a 1) (b 2)) (format t "~a ~a~%" a b)) to scope in Lisp
2:44:23
asarch
Because I could do in the first 5 lines of my code: (defun foo () ...) (foo), and then later in the line #1000 recall foo: (foo)
2:45:03
White_Flame
you can call (foo) after (defun foo ...) has been executed, and you can manually mung with ordering
2:45:52
White_Flame
JS is a very, very weak language when it comes to scoping & controlling source code ordering
2:46:02
White_Flame
so you really don't have to worry about a ton of stuff that JS makes you worry about
2:46:33
White_Flame
(of course, later versions of JS are cleaning things up, but your examples are kinda oldschool JS)_
2:47:15
White_Flame
so a lot of "How do I do <some JS thing>?" will be answered with "You don't need to"
4:02:13
JuanDaugherty
on the debian vs slime, the time came when all the debian cl things were completely removed
4:13:06
krwq
hey, why does this code produce warning that *foo* is undefined? (defun foo () (defvar *foo* 0) (incf *foo*))
4:14:49
Bike
the defvar is not run at compile time, so the compiler doesn't know that *foo* is special as it compiles the incf
4:15:57
Bike
if you need a special variable that's only used in one place, you don't need to use defvar, either
4:17:44
krwq
scenario is following: I want a macro which makes a non complicated place thread safe, i.e.: (defun pformat (control-string &rest args)
4:20:05
Bike
(with-gensyms (lock) `(let ((,lock (load-time-value (bt:make-lock)))) (bt:with-lock-held (,lock) ,@body)))
4:20:58
Bike
now, if you just had (let ((,lock (bt:make-lock))) ...), that wouldn't work since it would make a new lock for each time you execute it
4:21:17
Bike
load-time-value is a special operator that makes its operand be evaluated only once, when the fasl is loaded, and reused thereafter
4:21:42
krwq
Bike: I assume this will work also when I just load a file (ok if it redefines it then)
4:23:01
Bike
but then, if you're just loading the macro could be expanded more than once, giving it different gensyms anyway
4:23:49
Bike
(incf x) is just (setf x (1+ x)), it doesn't modify the value of x, just changes what it's set to
5:36:02
iqubic
I have a few questions about slime. There are a few places where the docs are woefully inadequete. 1) What does the STRING argument do in (slime-eval-print-last-expression STRING) and 2) What does the PREFIX argument do in (slime-eval-last-expression-in-repl PREFIX). I'm trying to call these from my init.el, but I can't because these are required arguments.
5:38:16
drmeister
If I have three lists '(a b c) '(d e) '(f g) and I want every combination of the first, second and third lists - what is that called? Outer-product? Cross-product? Is there a CL function to do this?
5:40:23
beach
I don't know what it is called, and there is no standard function to do that. You will have to write it yourself.
6:49:31
asarch
In PCL, chapter 8 there is a paragraph: "Common Lisp doesn't support macros so every Lisp programmer can create their own variants of standard control constructs any more than C supports functions so every C programmer can write trivial variants of the functions in the C standard library." Is it correct?
7:02:43
stacksmith
Nah, it's like "I don't work hard so my kids will waste my money" - does not mean that I don't work hard. Just unfortunate turn of phrase.
7:03:39
stacksmith
The point is that although you could change standard constructs, it does not mean that that's what macros are for.
7:53:02
panji
I am wondering what advantage using funcallable instead using method like in this sample https://gist.github.com/epanji/c93fea8ed9f7adaafb0a782f877dcc1b
7:53:23
panji
My understanding about metaclass is not that good, so i always wondering when the right time to use metaclass?
8:10:07
|3b|
panji: using funcallable-standard-class gives you an object you could pass to things expecting a function
8:13:09
|3b|
for example if you wanted something you could pass to mapcar, you could use a funcallable instance
8:14:05
jackdaniel
funcallable instances are a cool concept, because you can have slots and stuff in them, also you may specialize on them if you subclass this metaclass
8:16:14
|3b|
EQ is specified to not work on numbers or characters, I would just always use EQL instead of EQ
8:17:50
|3b|
if you know it is numbers (and want error if it isn't), and might be different types of numbers, use =
8:20:12
jackdaniel
panji: no, because 1 is not necessarily eq to 1 (i.e it may be stored in the pointer - immediate type)
8:21:17
|3b|
and since that's the only difference between EQ and EQL, it is easier to just always use eql (other people disagree, and think you should use EQ if you know it is safe)
8:22:02
|3b|
the idea is that EQ compares "identity", but numbers don't have any specific "identity" in CL terms
8:23:02
|3b|
where "identity" usually translates to something like "pointer" at implementation level, and numbers might for example exist only in a register so have nothing to point at
9:19:23
panji
|3b|: I added more test about mapcar you talk earlier (in https://gist.github.com/epanji/c93fea8ed9f7adaafb0a782f877dcc1b), and i still can't satisfy my curiosity about advantage using funcallable versus method. Maybe I should play around with it more often. :)
9:27:01
beach
panji: Yes, it is a function, but it can have other slots just like a standard object.
9:27:02
panji
|3b|: maybe i just don't know the right case to implement what you means. Anyway thanks. :)
9:33:29
beach
A generic function is a funcallable-standard-object: http://metamodular.com/CLOS-MOP/graph.png
9:35:37
beach
But if by #'method you mean a method, then no. You can't pass a method to function like MAPCAR.
9:36:21
p_l
... can you even get a reference to a method to pass it there?... wait, yes, you can, through MOP...
9:37:20
beach
panji: When you do DEFMETHOD, unless you have an explicit DEFGENERIC for the same name, you implicitly create a generic function with the same name, and that generic function is what becomes the result of #'method.
9:38:10
beach
panji: So you are not passing a method to MAPCAR, you are passing a generic function named CALCULATE.
9:42:28
beach
It is better to use slot accessors than to use slot-value and with-slots. Accessors are generic functions so they can participate in a protocol, whereas slots are implementation details that should be hidden.
9:44:25
beach
If you want your code to be portable across implementations, you can use the system CLOSER-MOP rather than the implementation-specific sb-mop.
9:45:52
beach
These days, I :USE only the COMMON-LISP package. I use explicit package prefixes for other symbols. If you :USE packages that may evolve, such evolution may break your code in the future, because a new version of such a package might export a symbol with a name that you also need from a different package.
9:49:09
panji
beach: I know about closer-mop, but it is just experiment code, so i don't think about compatibility. Thanks.