freenode/#lisp - IRC Chatlog
Search
12:30:08
ggole
isoraqathedh: you don't need inverted tests for that though, do you? (cond ((< x y) 'less) ((= x y) 'eq) (t 'greater))
12:31:28
ggole
I think I understand the left ~ lesser, right ~ greater thing you are suggesting though.
12:31:46
isoraqathedh
I do it like that because then the < = > lines up nicely and gives me the mindset that it's doing a trichotomy test.
12:33:34
isoraqathedh
Another factor to think about is that sometimes with predicates that aren't necessarily numbers, foo< foo= foo> can all fail but the result can still be meaningful.
12:34:17
isoraqathedh
(Like, if you had records with timestamps, and order is defined chronologically, but some records don't have timestamps.)
12:35:40
Shinmera
Arguably your comparators should already error if you pass them unorderable things.
12:36:03
ggole
Hmm, I would expect for the comparison to fail (placing the burden of checking for the timestamp-not-present case elsewhere)
12:37:39
igam
John[Lisbeth]: it's not more efficient, it's psychologically clearer. We are used to see the axis from left to right with smaller on the left and bigger on the right. So (and (<= 1 x) (<= x 4)) is more readily understandable as 1 … x … 4 than other orders.
12:37:56
isoraqathedh
Or, alternatively maybe your objects are actually games (in the game theoretic sense) and they have a quaterchotomy of game= game< game> and |GAME\|\||.
12:39:17
isoraqathedh
I think it's mainly a question of taste or style whether or not a trichotomy test should have the last case implicit.
12:40:51
ggole
It also allows for evaluating the expressions only once, which could avoid some otherwise unnecessary let bindings
13:16:24
phoe_krk_
What is the current legal state of the old Lisp books? Graham's ANSI CL and On Lisp, Touretzky's Gentle Introduction and so on?
13:26:40
flip214
should SLOT-VALUE (and therefore WITH-SLOTS) work with structures, too, or do they have an alternative macro?
13:28:14
H4ns
flip214: if you really can't stand defclass, write a wrapper macro and hate yourself 3 years later for it.
13:30:04
flip214
I'm still at the experience level where the redundant :ACCESSOR and :INITARG is noisy, sorry.
13:32:12
dlowe
instead, modeling objects as data upon which certain well-defined operations can be performed
13:32:49
moore33
Yeah, every slot doesn't need to be exported, even to the rest of the functions in a system.
13:33:09
Shinmera
Who even needs to type when you have paredit & mc? https://filebox.tymoon.eu/file/TlRneg==
13:37:21
flip214
H4ns: I've moved to a structure _in_this_case_ because sb-ext:atomic-incf won't accept accessor functions or (slot-value ...)
13:39:49
phoe_krk_
flip214: how do you indent them? the :ACCESSOR and :INITARG? this helps, at least in my case.
13:41:42
flip214
phoe_krk_: Yeah - but it's too much data for a single line either way, esp. with :type and :initform .... but having the slot spread over multiple lines isn't that nice either
13:41:52
warweasle
jdz: Haiku is the best way to write lisp. If a function isn't a haiku, then it's not simple enough.
13:43:47
phoe_krk_
I also have the Hide Show mode in Emacs. You can select a paren and hide it - then only the name of a class is shown.
13:43:53
flip214
phoe_krk_: yeah, I tried that in the past, too... still, there's a lot of redundancy.
13:44:38
flip214
I've used different ways in the past, but I'm not really satisfied with any of them
13:44:50
fiddlerwoaroof
The thing is that most of the clauses in a slot declaration aren't really worth an extra line.
13:45:16
phoe_krk_
I find it pretty unreadable if everything is crammed up in one line and therefore lacks any order my eyes can perceive.
13:45:38
phoe_krk_
fiddlerwoaroof: yes, they are short, but I found it much easier to understand them the moment I had them all lined up like this.
13:46:32
Shinmera
What I do like to do instead is use the :default-initargs class option where possible, since I care much more about what the initialisation forms are than about the rest. And they're usually also the longest part of it.
13:48:06
Shinmera
cramming an (error "SLOT required, but missing") into a line with the rest would be pretty unwieldy indeed.
13:50:47
flip214
as soon as a slot has :initform (make-hash-table :test #'equal) or :initform (make-array 10 :element-type 'fixnum) etc. the line is filled up anyway...
14:57:03
codesine
How would one go about displaying all interned symbols, for instance in the keyword package, (in-package :keyword) and then what?
14:59:11
isoraqathedh
One of the worst things about having :initform be a large form such as (error ...) or (make-hash-table :test #'equal) though is that too many of them clog up the echo area and it makes it bounce up and down.
15:01:18
isoraqathedh
But an entire function, one for each initform (because they're rarely exactly the same requirements) so that the mode-line would be a bit shorter?
15:02:22
oGMo
isoraqathedh: so they're similar, but not exactly the same? isn't that what parameters are for?
15:02:50
isoraqathedh
Which would clog up the mode line, and anyway isn't very different from just writing (error ...) and (make-hash-table.)
15:03:10
specbot
The Packages Dictionary: http://www.lispworks.com/reference/HyperSpec/Body/c_packag.htm
15:06:09
fiddlerwoaroof
codesine: you can also use loop: (loop for s being the present-symbols in 'cl collect s)
15:07:29
specbot
The for-as-package subclause: http://www.lispworks.com/reference/HyperSpec/Body/06_abag.htm
18:29:45
olpery
in implementing a simple Lisp interpreter, is it terribly wrong to have only lists, instead of pairs? A pair would just be a list with two items.
18:30:49
warweasle
olpery: A pair is just a cons cell with an object in both. A list is just a cons cell with a link to another cons cell (or nil)
18:32:20
olpery
yeah, sure, but i'm talking about implementation. A cons can be a list of two items. That makes it easy to create both pairs and lists, it seems.
18:32:40
warweasle
olpery: More simply, a cons cell is a pair of pointers. You can make a linked list and that's a list. If you add anything other than a cons cell or nil to the back of it, it's a pair.
18:33:02
|3b|
whether that is actually an important property or not sort of depends on the rest of your language, for example "pure functional" languages might care more, since they might want to share structure to avoid copying an entire list to make a modified version
18:33:11
dwrngr
A list of two items involves 3 "pairs", the first two of which hold a value and point to another pair, the last of which just holds a value and NIL
18:33:50
Bicyclidine
you can do stuff like (setf (cdr list) (list* 4 5 (cdddr list))) that would be weird/irritating if you had a list type with a length and so on
18:34:29
dwrngr
how would one implement a list to make it distinct from "a type that contains cons and nil"
18:34:45
warweasle
olpery: Some implementations optimize lists into a vector, but that's not specified and has issues.
18:34:53
White_Flame
olpery: using cons cells as (data . next) does use more memory, but running actual Lisp code will surely rely on that definition of lists
18:34:56
dwrngr
good point :P python list for instance... but in lisp i dont see a reason to make the distinction
18:35:39
dwrngr
since i use the (list ... ) function and rely on what it returns, i just call that a "list" haha
18:37:06
varjag
if you go with just copying the whole thing on modification, your O(1) operations become O(n) at its worst case
18:37:12
warweasle
olpery: Not to muddy the waters, I read an article which used hash tables as the basis data type (instead of cons cells) I haven't been able to find it again, however.
18:42:41
varjag
olpery: cons pair is not something unique to common lisp, it's the very basic cs101 single linked list node
18:42:46
White_Flame
you still don't have tail sharing with a list of vectors, unless the "rest of the list" is also a vector
18:43:04
varjag
so if you are going to implement list, you are going to implement cons cells at some level
18:46:27
|3b|
or the common idiom of (let ((a nil)) (dotimes (x 1000) (push x a)) (nreverse a)). if you don't share the list structure, that is o(n^2) instead of o(n)
18:47:02
warweasle
varjag: Actually it's a list with sublists. a tree would look like (((key . val) . (key . val)) . ((key . val) . (key . val)))
18:47:08
White_Flame
olpery: There are approx 4 styles of lists as used in Lisp. Regular lists, (1 2 3), improper lists (1 2 . x), a-lists ((k . v) (k . v)) and p-lists (k v k v k v)
18:49:02
|3b|
or prepending to an alist/plist to temporarily override an existing value without mutating the list
18:50:30
White_Flame
Now, you can certainly abstract lists away from cons cells, but it'll be a different language. If you're going for Common Lisp, or any form of classical Lisp, it's going to assume cons cells
18:51:54
White_Flame
* has an affinity for "set" and "sequence" as fundamental yet interchangeable data abstractions, but that's not Lisp
18:53:44
mood
isoraqathedh: It's 3 hours later now, but I really have to ask. When do initforms and the like ever end up in the echo area?
18:54:20
|3b|
probably with some syntactic shortcut like a reader macro on #\* that detects *foo*, since i'm used to that in CL
18:54:23
White_Flame
iirc, reading/writing scheme dynamic variables is not transparent; you need to call them explicitly
18:55:03
olpery
i don't have much experience with dynamic scoping, but it seems occasionally useful. Pushing "global" singleton state down a call chain.
18:55:31
|3b|
yeah, lots of things in CL are like that... don't need them most of the time, but then they make some edge case much easier :)
18:55:58
White_Flame
olpery: it's also great for thread-local variables, and uncommonly used configuration
18:57:06
olpery
White_Flame: wait... seems to be like dynamic scoping is just as problematic as globals for threading
18:57:34
varjag
what you do in cl mindlessly with an odd special form, you do in scheme by writing your own framework and and a thesis paper
18:59:09
White_Flame
if you have a (defvar *foo*), though, that value is globally visible & mutable outside of any other bindings
18:59:53
White_Flame
access to special variables first checks to see if it's bound thread-locally, then hits the global symbol-value if it isn't
19:02:17
warweasle
White_Flame: Is it like forking a process where each thread has a copy of the environment?
19:07:16
White_Flame
each thread has its own bindings it can create, and defaults to the shared global symbol-values
19:44:58
Thulsadum
the random state is quite bloated... i'd like to keep some states in structures to generate some determinstic (yet random) structures
19:47:09
Thulsadum
are there `seed` like function working on smaller integegers? i think a single dword/qword would be enough for my particular application
19:47:23
Bicyclidine
you kinda need that much state if you want a half decent PRNG. if you're ok with a shittier one, you could write up an LCG in thirty seconds
20:03:35
|3b|
if you don't need portability, you can use sb-ext:seed-random-state on sbcl to seed with a smaller integer
20:07:52
|3b|
though depending on how repeatable you need the sequences to be, you might want a separate random number lib anyway
20:09:04
|3b|
since implementations might decide to fix or improve their RNG at any point, changing the sequence you get from a particular seed
20:16:36
Shinmera
Thulsadum: By "the random state" are you referring to the random-state library or?
20:19:05
Thulsadum
Shinmera: i meant this http://clhs.lisp.se/Body/t_rnd_st.htm#random-state (i.e. the sbcl implementation)
20:19:26
Shinmera
Thulsadum: Ah. Well, there's a library called random state that implements a few PRNGs http://shinmera.github.io/random-state/
20:21:30
Shinmera
Well, you might need to evaluate it first. Since it's using classes and GFs a lot it might be too slow for your use-case.
20:22:45
Thulsadum
i'm in the prototyping stage atm. I just want to get things done and then i'll profile bottlenecks. ;)
20:26:35
Bicyclidine
fortuna is pretty neat, but it's already in ironclad and maybe you need to do some bullshit for side channel attacks, dunno
21:16:55
jasom
Bicyclidine: salsa20 has only 64 bytes of state and is a lot better than "half decent"
21:22:19
pjb
minion: memo for olpery: you should read AIM-8, notably the last section. http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/aim-8/aim-8.html
22:23:52
Shinmera
It's during the semester for me as well. Didn't stop me last time, and won't stop me this year either.
22:25:02
sjl
unfortunately it's during the "three week class" here where you go to the same class every day for ~4 hours for three weeks
22:35:09
sjl
I finished undergrad in 2008 and then worked in the real world for a while, decided to pack up my life and go back to school. It's refreshing.
22:37:35
p_l
I miss my uni years a bit, I guess, partly if not mostly because of easy access to library etc.
22:37:58
p_l
OTOH, I had missed so many opportunities there and been in some of the worst dumps of my life...
22:39:16
p_l
DeadTrickster: ouch. I mostly went for older stuff that students tended to not take unlike "current textbooks", learnt probably more :D
22:41:16
DeadTrickster
and you are right, it was damn hard. All I could afford at that time is student ACM with probably some parts of IEEEE
22:42:19
p_l
I was considering doing an insane attempt at getting place in funded PhD programme at Oxford, but it didn't pan out :)
22:45:13
DeadTrickster
My MSc thesis went surprisingly well (A) but still I don't even understand it now
23:44:36
sepi
Why does (drakma:http-request "http://example.com" '(("queryString" . "testblob"))) give me an "odd number of &key arguments"?
0:00:58
sjl
Why does SBCL choose (unsigned-byte 15) as the type for this vector instead of (unsigned-byte 14)? http://paste.lisp.org/display/311828
0:04:59
Bike
anywho, if you have a type, you can see how it will be packed in an array with (upgraded-array-element-type type)
0:09:36
Bike
aaaanyway, on sbcl you can do some magic, (map 'list 'sb-vm:saetp-specifier sb-vm:*specialized-array-element-type-properties*), and get a list of all the stuff sbcl knows how to pack
0:12:16
sjl
so if the type is (unsigned-byte 15) it's probably aligning to 16bit boundaries, and using the extra bit for a tag bit of some kind
0:12:40
sjl
but because it won't let me actually see that internal bit it's just telling me it's an usb-15
0:16:09
Bike
yes, but in the days of yore setq pretty much just did whatever, including make up variables without a warning
0:19:20
Bike
it's pretty much random repl usage, not like, lasting code, except by virtue of being an example in the standard
0:20:20
phoe_krk_
Yes - but in modern days, using setq on undefined variables is not common courtesy.