freenode/#lisp - IRC Chatlog
Search
22:30:44
mfiano
Actually, the Norvig/Pitman LUV slides recommend using ?/! if you are to be consistent in your naming.
0:33:06
Gnuxie[m]
Using something earlier in the form in one of the pairs and not wanting the updated place
0:38:21
Josh_2
well they aren't all that different, seems similar to let and let*, one guarantees the order, the other doesnt
0:40:07
Bike
let* guarantees that bindings take place in an order. let guarantees that bindings do not take place. similarly, setf guarantees that one assignment takes place after the other, and psetf guarantees that they don't
0:40:49
Bike
well, rather than assignments taking place, psetf guarantees that all values are evaluated before any assignments take place
0:51:28
Gnuxie[m]
I would be very cautious to assume an efficiency guarantee from anything like this, even if there did exist one
0:53:29
Gnuxie[m]
Mostly because it's a waste of time to think about, and will rarely ever be considerable enough to count even before considering how idiomatic it is
0:57:56
Bike
setf and psetf aren't competing, or something. they just do different things. if you asked whether lists are better than arrays i'd be like, well, depends on what you're doing. same principle
1:14:01
aeth
Use it when you don't need to do something fancy, too. It tells the reader that in this gigantic list of like 10+ PSETFs, none of them are supposed to depend on another (and it prevents the programmer from introducing a bug that accidentally does so)
1:14:27
aeth
You probably want to default to PSETF because you normally don't want dependencies between lines in a multiline SETF
1:29:13
aeth
(* Default to using PSETF when there's more than one form. Otherwise, SETF is the simpler form. So there is a bit of stylistic complication.)
2:33:26
Bike
oh, and psetf always returns nil, which is pretty useless, unlike setf which returns the last stored values, which is sometimes useful
2:41:05
Bike
this will not include variables that are proclaimed special but not bound, as by (defvar *whatever*)
2:41:40
Bike
if you want variables in the cl-user package specifically, you can use do-symbols or do-external-symbols instead
2:47:03
aeth
So it should be phrased as: If the is just one set, use SETF. This sometimes has a useful return value, too. If there is more than one consecutive set, then unless you need the dependency between them, prefer one PSETF over one SETF (and especially over many SETFs in a row).
2:49:18
aeth
(setf x 42) (psetf x 42 y 53 z 64) (setf x 42 y (+ 11 x) z (+ 11 y)) ; extra caveat: always linebreak... this is one line just for IRC
3:40:46
antonv
hi, does anyone know how to use rowsell for Travis CI today? It fails to install using the install-for-ci.sh (https://github.com/roswell/roswell/issues/463)
3:44:14
ozzloy
Bike, i just did (length (let ((res (list))) (do-external-symbols (sym *PACKAGE*) (when (fboundp sym) (push sym res))) res)) and got 0
3:45:13
ozzloy
i read that it is the default. when i evaluate that, i get #<PACKAGE "COMMON-LISP-USER">
3:45:44
Bike
and is your method named by an exported symbol of cl-user? or, more likely, did you not export it, or define it in some other package?
3:46:52
ozzloy
i'm looking to find all defvar'd and defun'd things, not necessarily things that have been exported
3:47:47
ozzloy
i'm getting a feel for it. seems like it's analogous to a package in java, or a module in racket, etc
3:48:49
Bike
packages are namespaces, so it's similar to some other languages, yes. although you should keep in mind it's strictly a naming thing. for example functions don't "belong to" packages, only their names may.
3:48:49
ozzloy
hmm... when i do all symbols, i get 14150 things. is there a way to see just the ones i've made during a session?
3:49:26
Bike
anyway, so symbols are divided into these namespaces. the namespace you start out in, cl-user, is not something made for an external interface, it's more for messing around in the repl in.
3:49:46
Bike
do-all-symbols iterates over all symbols in all the packages. do-symbols and do-external-symbols only iterate through the symbols in one package.
3:50:14
Bike
(there are also symbols that are not in any package, but they don't usually name global variables or functions, so i'm skipping that)
3:51:00
Bike
there is no particular way to see just what you've defined. a problem with that is that functions newly defined since the lisp started up may include e.g. IDE stuff you didn't define yourself
3:52:34
Bike
(let (c) (do-symbols (s "CL-USER" c) (when (eq (symbol-package s) (find-package "CL-USER")) (push s c))))
3:52:58
Bike
this will collect symbols that are (a) accessible from the cl-user (repl) package, and (b) are not part of some other package
3:53:12
Bike
for example your do-symbols form will include every symbol in the CL package, which is accessible from the cl-user package
3:59:39
ozzloy
i mean, i guess the operator is named "1+" and so it is still prefix... but the "+" though!
8:28:53
moon-child
a slightly more sophisticated solution would also look for quotes inside the tag and ignore <> inside of those
8:30:42
moon-child
(I don't remember if you can escape single quotes in html, if not then the second branch can just be '[^']*')