freenode/lisp - IRC Chatlog
Search
19:05:02
andyloveslisp
I've successfully parsed a json request into an alist of string. Is there a best practice way of manipulating this to an alist of symbols? I was just thinking of using (intern ..)
19:07:16
shrdlu68
After further deliberation, the committee placed the CLHS in the Index Librorum Prohibitorum.
19:08:21
phoe
Just don't be worried if you suddenly see symbols like |value| or |randomURIDesignator| in your package.
19:08:47
phoe
Also - be wary that once you intern these strings, they will stay around until you delete the package, which might mean forever.
19:09:21
phoe
Which might mean that sending arbitrary JSON to your server will be able to fill up its memory by interning arbitrary strings inside your package, making them persistent and uncollectable as garbage.
19:19:08
phoe
jurov: from what I've researched and what I've implemented in the library above, there are three bad things that can happen.
19:22:14
phoe
you'd more or less need to implement a Lisp reader to recognize matching parens, at which point you've reinvented the wheel.
19:23:17
jurov
I was thinking "maybe there's some combination of standard reader options that can read safely".. so there isn't?
19:29:14
andyloveslisp
I can pull apart the string before I read it? There should be no parenthesis in my inputs, so I could block the process on discovery of any.
19:30:34
phoe
Second: ...actually, if you're not reading S-expressions, then hacking around the Lisp reader won't work. See point one.
19:31:29
White__Flame
it's theoretically nice to pull in numbers and strings, but if there are slight format discrepancies they'll bite you
19:31:40
shrdlu68
If the string should not contain parens, then simply blocking a string with parens and otherwise reading should be fine, no?
19:32:12
White__Flame
if a string contains "foo", then READing it will create the symbol FOO, having applied the read case
19:32:38
andyloveslisp
well I grab a json string from hunchentoot, use string functions to inspect it, then use read functions to convert to lisp symbols/numbers.
19:33:51
White__Flame
but you'll probably need to upcase it manually as well, if you want it to look like normal symbols
19:34:02
andyloveslisp
Well there are numbers, and intern creates a |1| symbol rather than the number 1
19:34:39
White__Flame
andyloveslisp: wait, if you read {"a":1}, you'll get ("a" . "1") in your lisp-side a-list?
19:35:42
White_Flame
you can do (eq str1 str2) and it'll be just as fast, probably not correct though ;)
19:35:43
andyloveslisp
no I parse using yason from {"a" : "1"} to ("a" . "1") then I'm on my own from here.
19:37:11
andyloveslisp
yes it's correct but I eventually want (a . 1) to feed to the rest of my program
19:38:30
White_Flame
unless you know for certain that that particular field intends to hold a number in string format
20:20:58
theseb
I'm fascinated by these minimal lisps with few primitives. Can these little langs can be USEFUL....All I can think of is maybe as teaching tools!?!
20:21:51
White_Flame
but when they're embedded into a program, they can be quite useful for scripting functionality
20:21:57
theseb
they're just sooo cool and mathematical and elegant i want to do something with the little lisp i made
20:23:53
pjb
I may be wrong, but I see no reason why CL stream would be implemented using C FILE. They're implemented using directly POSIX file descriptors.
20:24:37
haom
pjb: i want to pass a file pointer to a c function through CFFI, do you have an idea how i could do that?
20:25:36
pjb
haom: beware however that then you will have two buffers, one in the lisp side, and one in the C side. Better flush your buffers before changing sides.
20:30:43
theseb
White_Flame: embedded languages!!!! yes! for when Python and Java and Common Lisp are a little too heavy to be embedded..yes makes sense!
20:32:18
theseb
White_Flame: i've been a dev for 20+ years....i've never had to "embed" a lang in an app...when does that come up?
20:33:41
White_Flame
but seriously, game scripts, utility macros, configuration languages, all of that stuff is much more useful to consider dynamically at runtime
20:34:18
White_Flame
useful for the end-user that is, and can reduce a lot of developer burden too, if the main application is C/C++/Java/etc
20:37:42
didi
shrdlu68: For instance, say I want to mark a list with a sentinel, so I want when to stop processing. I push (defparameter *sentinel* '(nil)) to it. Even if '(nil) ends up in the list, it won't be EQ to *sentinel*.
20:52:17
Bike
well the thing is that eql and eq have same results except on characters and numbers, and neither of those are one where you can deliberately allocate a new instance.
21:07:48
pjb
EQ is an implementation introspection mechanism. We only have to know about it because some old function use EQ instead of EQL, and therefore cannot be used with characters or numbers. (eg. GET). (cf. clhs eq)
21:22:22
nyef
New possible plan for the MacIvory: Get a keyboard from wasdkeyboards, and a 3-button PS/2 mouse. Use a PS/2 adaptor on the keyboard. Run the PS/2 connectors to an AtMega328, and from the AtMega328 to an ADB port on the IIfx. Program the microcontroller to translate keycodes and mouse events to what is expected by the MacIvory and the "mousekey" driver.
21:27:54
nyef
Mmm. It's that, or trying to get the mousekey 2.0 driver working with the MacIvory, or trying to find an older version of the 3-button mouse that I have.
0:15:52
didi
What do you think of my `find-sorted' function: https://paste.debian.net/hidden/d4868f9e It finds an item inside a sorted sequence. The purpose is to stop short if the item can't be beyond a certain point.
0:23:00
nyef
But under the circumstances, if you're even trying this, the list is probably the wrong data structure in the first place.
0:27:43
TruePika
quick question, is anyone else having DNS lookup issues from Google's servers? I can't check anywhere other than IRC without a DNS...
3:25:49
drmeister
Does anyone do much multithreaded programming? Does a condition-variable pass a mutex from one thread to another?
4:21:15
H4ns
drmeister: no, a condition variable complements a mutex. one thread grabs a lock on the mutex, then waits for the condition variable to be posted. when the wait returns, the condition variable was posted by another thread and the mutex is locked.
4:21:49
H4ns
drmeister: it is basically a low-level protocol that can be used to implement e.g. semaphores or other higher-level constructs.
4:23:10
H4ns
drmeister: like all things concurrent, condition variables are not very easy to explain and i may have done a terrible job at it :)
4:24:46
l04m33
drmeister: as for ECL, it avoided pthreads on purpose, for some portability reason iirc
4:35:48
drmeister
l04m33: I see. It uses pthreads for threads themselves, but not mutexes or condition variables. It also uses pthreads rwlocks.
4:37:07
drmeister
Clasp uses pthreads mutexes and condition variables. They don't mix well with some of the Common Lisp code in the ECL "MP" package.
4:53:22
drmeister
l04m33: Not quite. I implemented process, mutex and condition-variable types in C++ using pthreads. Then I copied the ECL mp.lsp Common Lisp source thinking that it would work unchanged with my process, mutex and condition-variable types. This has worked over and over again as I've developed Clasp. Not this time though.
4:54:03
drmeister
The ECL implementation of mutex keeps track of the mutex owner. I had fudged something that didn't quite behave the same way and so mp:with-lock didn't work properly.
4:54:36
drmeister
This may come back to bite me - maybe the reason why ECL implemented mutexes was because pthreads mutexes don't keep track of their owner and it's necessary for some reason.
4:55:03
drmeister
But when I changed the implementation of mp:with-lock, now all of a sudden slime works in :spawn mode with Clasp again.
5:00:24
l04m33
drmeister: I stumbled into some article explaining why ECL dosn't use pthread condition variables, but I can't find it atm
5:11:39
l04m33
drmeister: they wanted to support Windows, not quite relevant to your problem here though
5:12:05
mkennedy
When I'm looking at a disassembly of a function in SBCL, it often says up the top "; no-arg-parsing entry point" What is meant by that?
5:24:50
phoe
If Franz can roll with their own CL specification based on dpANS2, then I can roll my own CL specification based on dpANS3.
5:42:37
jackdaniel
shrdlu68: check out https://common-lisp.net/project/ecl/static/ecldoc/Extensions.html#System-building
5:47:19
drmeister
https://usercontent.irccloud-cdn.com/file/uB5kqu1b/set-pprint-dispatch-mir0.dot.png
5:49:23
drmeister
I'll have to investigate further why it didn't dump the mir of what we wanted it to dump.