libera/#commonlisp - IRC Chatlog
Search
1:22:13
semz
Yes, which is why the error should be from your code, and not some internal thing from the hash table implementation that may or may not trigger at all
1:22:21
White_Flame
and if size+speed was still a concern, I'd seriously consider the symbol-plist off that
1:22:57
Guest74
semz: I don't know what you're arguing. That some implementation that doesn't seem to exist will be written poorly?
1:24:00
semz
Or that somebody is having "fun" with someone running whatever software ends up using it and manages to coax the program into doing something stupid.
1:24:19
semz
The point I'm arguing is that this problem doesn't even exist if you use the simpler implementation - a normal hash table.
1:25:14
semz
As far as I can tell, you're trading correctness and a lot of effort for basically nothing
1:25:31
Guest74
I think the point you're arguing exists regardless if you're using hashtables at all. To say it is a problem with a minimal perfect hash table that doesn't seem to be implented yet, well, i don't know what to think about that.
1:26:22
Bike
isn't the issue that a minimal perfect hash table by definition is not defined for unexpected inputs, and will in fact return some random crap instead of signaling an error
1:26:40
Alfr
Guest74, it's perfectly reasonable for a gethash like function for a minimal perfect hash table to return any object or even read out of bounds. Given the hash function, it doesn't even need to store the keys, as any key provided will by the very definition of perfect hashing map to some position the implementation assumes to store the key's vale. So, it you feed it something which isn't one of the original keys, the results might be quite unexpected.
1:27:50
Bike
like, if it can recognize an unexpected input and do something else, it's not a minimal perfect hash table.
1:33:42
Bike
yeah but if you want The Speed then you skip the boring stuff you do in a general hash table like make sure the key is actually equivalent
1:34:26
semz
Guest74: This isn't flamebait, I'd sincerely like to know this. Do you have C/C++ experience?
1:40:28
Guest74
we can always ask Vseloved if he ran into any problems. I'll have to check out his library.
1:47:16
Guest74
if you store the key with the value you just check that they are eq before returning whatever the hash pointed to. If you want to reduce the problems of malicious software or continous user error. still seem to get more speed and less memory if that's you're concern.
1:51:03
_73
What do you think of this general pattern for a closure that can perform dynamic dispatch? http://dpaste.com/6WNBXQGKP
1:58:35
Bike
_73: case doesn't evaluate the keys, so you don't want those quotes. also, usually one would just use defstruct or defclass.
1:59:02
Bike
also if you do it this way you don't need an alist, you can just close over three variables, and the binding shouldn't be special.
2:03:43
_73
If I were to use a struct for `people` instead of a length 3 list do I gain anything in type safety?
2:05:31
Bike
sure, it means you don't get garbage out if you accidentally have (fred ("aggravated assault" "23 years")) in there
2:06:00
_73
Guest74: right that is a given but does not matter if I never plan on inserting into the alist
2:07:07
Bike
i could write this something like (defstruct person gender age marital) (defvar *people* (list (cons 'fred (make-person ...)) ...))
2:07:37
Bike
and then maybe (defun gender (name) (person-gender (cdr (assoc name *people*)))) etc instead of the dispatch thing
2:07:58
Bike
also, just realized there's another bug, since assoc returns the pair rather than the value your code won't work
2:08:07
pjb
(defstruct person name gender age marital) (defparameter *persons* (list (make-person :name "Bill") (make-person :name "Mary")))
2:08:29
pjb
(find "Mary" *persons* :key (function person-name) :test (function string-equal)) #| --> #S(person :name "Mary" :gender nil :age nil :marital nil) |#
2:10:47
Bike
really i read too quickly because i read "closure that can perform dynamic dispatch" and thought of the scheme pattern of using closures as objects, but you're not actually doing that here. in fact, if *people* is a special variable like it looks like, there's not even a closure involved
2:26:17
Guest74
oops, i think I need more dbus services besides firefox. Just crashed my browser testing a function. This dbus implementation seems like less of a good idea now that I see there's not much there if you aren't running kde or gnome.
4:31:25
phantomics
Morning beach, is anyone around here using Allegro CL? If so I have something amusing for you to try
4:48:56
ns12
Does "Object-Oriented Programming in COMMON LISP: A Programmer's Guide to CLOS" by Sonya E. Keene describe CLOS as it appears in ANSI Common Lisp? Or is the book about pre-ANSI CLOS?
5:18:16
beach
ns12: ANSI pretty much incorporated CLOS as it was defined, or the subset that was necessary for the standard.
10:46:43
VincentVega
So, in a situation like this https://pastebin.com/Ft6qYNMa , what can I do to optimize away the WHEN clause? Any way to declare FLAG constant?
10:48:13
phoe
that's slightly subpar because it leads to code duplication, but you do seem to want code duplication - you want to return different functions depending on the value of flag
10:49:17
phoe
but, good golly, I hope you don't use microoptimizations like these for simple functions like that
10:49:49
phoe
VincentVega: not really; you basically want to return different anonymous functions based on the value of FLAG
10:50:16
phoe
and LAMBDA is not a good abstraction for that, because it always describes a single body of code
10:51:30
phoe
you can only try to hide it behind some sort of macrology, but adding conditionals like that would likely require code walking in order to find the conditionals in the code
10:52:21
phoe
like, if a hypothetical FLAG-LAMBDA like (flag-lambda (x y z) ...) expands into conditionals based on X, Y and Z, then (flag-lambda (x y z) (... (... (flag-when x ...))))
10:52:46
phoe
this requires code walking so FLAG-LAMBDA can recognize how to skip or not skip the inner FLAG-WHEN invocation
10:53:33
VincentVega
phoe: Hmm, I see what you are saying, that makes sense. But to avoid code walking, I could write a seperate macro too, so that's cool. Well, thanks for explaining this!
10:55:14
Nilby
I don't think you need walking if you don't care that there's two versions of the lambda
10:55:43
phoe
Nilby: I mean, one of these lambdas needs to have the PRINT call and the other needs to not have it
10:56:44
phoe
so something like (flag-lambda (x) (flag-when x (print "foo")) (+ 1 2)) expands into (if x (lambda () (print ...) ...) (lambda () ...))
10:57:14
phoe
and I just realized that you can avoid code walking - you can pass information in &environment
10:57:47
phoe
and it will cause FLAG-WHEN to expand into either (progn) for nothing or (progn ...) - depending on whether a given flag is meant to be set for the given generated lambda
10:58:30
phoe
VincentVega: I can sketch out a solution later today if you're interested and/or don't know how to start
10:59:07
VincentVega
phoe: I think I know what you are saying, I am playing around with code rn to see what works best : )
11:12:44
VincentVega
I mean, the other way is to do this generally like phoe suggested. For multiple variables, that is, would be useful. Maybe I will even make it.
11:31:56
VincentVega
phoe: Nilby: OK, it's actually quite nifty with a symbol-macrolet https://pastebin.com/WN3NU68j except for the deleting unreachable code warnings.
11:42:49
phoe
give me a few hours to finish work and then I'll be able to show you if no one does before me :D
11:46:09
Nilby
Nice. Nearly zero run cost conditional logging. Probably less code bloat than C++ templates. I'm curious to see phoe's extra fancy way.
11:47:52
VincentVega
Nilby: yep, with a custom when-flag, the warnings are gone, will be curious to see another way too : )