freenode/#lisp - IRC Chatlog
Search
23:34:38
jcowan
It's interesting in that you don't have full control of which method is chosen, only that it will work (and therefore all methods must produce the same results, just by different means)
2:50:52
jcowan
Is the pattern of multiple values that SUBTYPEP uses (first value is the value, second value is a boolean indicating its validity) a common one in CL code?
2:53:45
Bike
i think alexandria:type= uses the same return values, but that's for basically the same thing.
3:25:41
fouric
does anyone know of a lisp reader that preserves the locations of the forms that were read in in the file?
3:26:22
fouric
that is, when i invoke said hypothetical READ, it returns not only the results of normal READ but also line numbers and character indices/columns of where each atom/list was found
3:34:28
Bike
beach's reader has stuff for source tracking https://github.com/robert-strandh/Eclector/
6:13:18
aeth
pfdietz: Not entirely similar, because it's actually the default value, which happens to have the default default value of NIL
6:14:06
aeth
Although I guess you could see an overridable value there as being sort of like the EOF value in the read functions.
6:32:54
rk[ghost]
ah, aye aye. any one i imagine is better than me writing from scratch in native CL or worse calling grep/sed as an external function :P
6:34:48
rk[ghost]
hmm, however looking at the history.. last change seems to be in 2k8.. which is fine and dandy in most cases, but html5 was 2k14...
6:36:38
beach
I do know that gilberth (the author) worked hard to make it parse traditional, but syntactically incorrect, HTML.
6:41:12
MichaelRaskin
You mean bookmark export? There the problem is simpler, because it is known to be valid and non-fancy
6:42:20
rk[ghost]
i just thought, psh, why i am at it may as well learn a good html parser lib just in case i plan to do other jazz
7:23:26
beach
(defun cat (&rest strings) (apply #'concatenate 'string strings)) something like that.
8:10:13
makomo
no-defun-allowed: i think this is what you're looking for http://metamodular.com/CLOS-MOP/slot-value-using-class.html
8:14:16
no-defun-allowed
it'd be awfully spammy if most of the room went "i don't know much about sly"
8:17:01
sink
Better question then: How do I start understanding a large and underdocumented CL project? I feel lost just reading the code. How do I start interactively fiddling with it?
8:19:03
sink
I'm looking at a CL project in this case. I've actually had a much nicer time debugging Elisp issues (mostly because it's not doing anything fancy, just routine functions for scripting and text editing).
8:22:07
fiddlerwoaroof
Or, if you have a code sample that uses the project, maybe look at the source of the functions that your code sample uses and play around with the inputs in the repl
8:22:13
sink
no-defun-allowed: That's how I found myself lost in source code. I jump to one function that throws an error, then try to figure out what defun+ is, and before I know it I'm swamped in macros.
8:22:43
sink
fiddlerwoaroof: I see everyone talking about this Test Driven Development and testing thing. Where do I start?
8:23:26
no-defun-allowed
anything that touches agile or extreme programming only deserves pointing and laughing
8:24:00
jackdaniel
pfdietz: do you have by chance some code snippet to show how you implement slot-unbound condition to lazily compute values? you've mentioned it the other day and it sounds clever, but I'm curious how did you implement that
8:24:05
fiddlerwoaroof
no-defun-allowed: I work at a TDD-heavy shop, it actually puts some useful design pressure on your code
8:24:20
no-defun-allowed
cause your test cases have to be pretty damn good or you lose where you didn't test
8:24:32
rk[ghost]
hmm, i found SLY on github: as for tests see test/ directory. another good place to start is to read the illustrated guide linked there.
8:25:12
sink
rk[ghost]: The guide comes installed as an info package when you install Sly. It's really nice. Unfortunately, it says nothing about highlighting in the REPL.
8:25:55
no-defun-allowed
jackdaniel: slot-unbound is a gf which gets called with the class, instance and slot name, you could write a specialiser over the class and slot name which computes it i assume
8:28:14
rk[ghost]
err, this may be a silly question but, is there a function that returns a string the way (princ) prints it?
8:28:16
fiddlerwoaroof
So (setf (slot-value ...))) as the last form would bind the slot and return the computed value
8:29:55
fiddlerwoaroof
rk[ghost]: depending on the context you might use FORMAT's ~A directive and/or WITH-OUTPUT-TO-STRING
8:30:32
rk[ghost]
hmm, i think i asked the wrong question. let me re-evaluate what i am trying to ask :P
8:30:33
no-defun-allowed
jackdaniel: here is a minimal working example: https://pastebin.com/UeWtyDpz
8:32:22
rk[ghost]
my string has " in it.. princ shows as " but the string returns with \" .. this mangles things for me.
8:33:09
fiddlerwoaroof
The string will always have the \" in the printed representation of the string
8:33:12
jackdaniel
rk[ghost]: it is just notation, how otherwise would you print a string which is delimited with " ?
8:34:47
rk[ghost]
in the end, i was using hunchentoot in the past to create webpages.. i found that when i was trying to make hyperlinks, i was getting the \" appearing and it wasn't redirecting correctly
8:35:29
rk[ghost]
however, now i was just writing a new function, but i am currently seperated from the hunchentoot code.
8:35:43
jackdaniel
you may embed strings in a template with format (format nil "http://~A/bar" "my-url")
8:35:48
rk[ghost]
so let's forget the problem until i am at the point i am testing and breaking things.
8:37:01
rk[ghost]
lemme post my current lame code that i would have passed to the page generator in hunchentoot..
8:37:26
no-defun-allowed
ACTION zaps rk[ghost] thinking the other zap got broken cause riotdotim is a pile of garbage
8:37:31
fiddlerwoaroof
jackdaniel: I just mean that something like quri or puri solves a lot of the corner cases in uri generation for you
8:39:18
jackdaniel
this looks like a primary library functionality. by "magic" I understand some unobvious (but useful by some means) processing steps
8:40:01
fiddlerwoaroof
jackdaniel: yeah, I generally use it to mean hiding annoying details of the problem domain from the user.
8:40:50
jackdaniel
I won't argue because it is a subject of opinion, I reserve word magic for other things
8:42:08
no-defun-allowed
anyway i remember a kind of string lookup tree which used some clever stuff about strings to speed up comparisons, anyone know much about that?
8:42:34
no-defun-allowed
i remember it'd dispatch on each char so you only have to char< or char> instead of string< or string>
8:45:00
no-defun-allowed
rk[ghost]: (print-hyperlink (make-hyperlink "\"><script>alert('pwned')" "" ""))
8:45:08
rk[ghost]
aye, i started to get that hint from what you were saying, but i pasted what i had going anyway
8:45:41
jackdaniel
~s prints string as a string (so it will add \" itself), ~a puts a string without the quotes
8:46:21
rk[ghost]
ah, OK.. lemme try to get access to the server with hunchentoot code, add this functionality using the format and see if it "just works"
8:56:46
rk[ghost]
format most definitely is handy.. although an embedded language makes code look funny.. just so not lispy:P
8:59:36
ogamita
rk[ghost]: have a look at https://github.com/informatimago/lisp/tree/master/common-lisp/html-generator or cl-who.
9:00:15
ogamita
jackdaniel: note that ~S is not enough for cdata (or pcdata). You need a specific cdata-escape function!
9:01:43
rk[ghost]
ogamita: aye thanks. first link doesn't seem to support html5.. but cl-who does so :D
9:02:28
rk[ghost]
with a slow brain late at night, i think i spent 4 hours doing something that should have been a 5 minute jot XD
9:04:05
ogamita
rk[ghost]: that's typical of lisp, once you've learned, you'll be able to do quickly things that took hours before.
9:14:39
aeth
rk[ghost]: Is this your keyboard? https://en.wikipedia.org/wiki/Space-cadet_keyboard#/media/File:Space-cadet.jpg
9:15:26
aeth
My favorite thing about that keyboard is that it has two sets of () and the {}s are way out of the way to punish you for even thinking about using them.
9:18:24
rk[ghost]
http://i.ebayimg.com/images/i/222462922753-0-1/s-l1000.jpg < (not a picture of mine, but such is my keyboard)
9:28:51
rk[ghost]
ogamita: that suppose to be "know" or are you asking if i am "currently" xmodmapping?
9:29:34
rk[ghost]
that keyboard has a built in microcontoller such that it sends the appropriate keycodes.. so you can plug it in to any computer and it keeps its mapping with it
9:30:12
rk[ghost]
so i have fancy things like a key that does ctrl+a and ctrl+b (i use both screen tmux together >:D)
9:31:17
ogamita
rk[ghost]: for when you are not at your computer; you can prepare a .xmodmap file to map any standard keyboard close to your custom layout.
9:32:56
ogamita
It's important: if you don't make the computer adapt to your ways, the computer-human system will be prone to cockpit errors.
9:33:06
rk[ghost]
ah, fair enough.. although the placement of the keys are slightly different.. and i am currently (/me hides) on a winbox and sshing to a jumpbox which has gentoo on it, but isn't my dev box..
9:33:28
ogamita
it is after such fatal errors, that the first thing I install on a new system (even before the kernel), is emacs!
9:36:27
ogamita
rk[ghost]: I also use ssh, from a local X ;-) But on Windows and macOS it's also possible to define keyboard mappings.
9:39:30
ogamita
rk[ghost]: :-) if it's downstairs, yes, just do that. I thought you had to take a plane to fetch it!
9:40:54
rk[ghost]
ogamita: it is 4:40AM localtime .. at this point i should sleep, but i had coffee late.. so in zombiemode..
10:41:31
elderK
Man, I'm having a bit of trouble. I think it's mostly a conventional-thing but, like, I'm not sure how to best organize my stuff.
10:41:50
elderK
Like say I have a class, and a bunch of generic methods that are to act on instances of that class (or subclasses.)
10:42:34
beach
There is no such thing as a generic method. There are generic function and there are methods ON those generic functions.
10:42:35
elderK
What about say, independent types you define with deftype? Where do they go? Or parameters?
10:43:19
beach
OK, so the answer has to do with what you consider part of the protocol, i.e. the part of the module that is visible to client code.
10:43:46
beach
I put the definitions of my generic function that are part of the protocol in a separate file
10:44:29
beach
Like this: https://github.com/robert-strandh/SICL/blob/master/Code/Environment/generic-functions.lisp
10:44:35
elderK
Right. And what about like, say, complex macros and things? Do you have them in the protocol file? Or do you define them elsewhere but make sure they appear in the proper package?
10:45:13
no-defun-allowed
aeth: I swap [] and () in Emacs, it's just 4 lines of elisp to set up the mappings and doesn't cost me anything in hardware.
10:45:36
beach
elderK: You can put them where you like, but you export the symbol that names the macro.
10:46:02
pfdietz
Generic functions can dispatch on more than one class, so there generally isn't a single class they're associated with. This is unlike methods in typical OO languages that dispatch on a single argument.
10:46:23
elderK
beach: Just, having a hard time. Like, I have a class and a bunch of generics. I have a bunch of helper functions and things too. Now, the generics are for public use. The helpers, are not.
10:46:40
elderK
In C, I'd have those public functions in the header, and the internal things in the .c file.
10:47:06
elderK
So I was wondering if there was a similar convention for Lisp, some way of separating the public from the private, as it were.
10:47:55
elderK
Like, there is a certain way I lay out my C files, say. Certain things are always before other things.
10:48:24
elderK
Like say, the defclass bfore the generics that are expected to work on instances of that class?
10:48:44
pfdietz
Well, certain things HAVE to come first. Definitions of macros must occur before their uses, for example.
10:48:55
beach
elderK: Otherwise, when the class is loaded, a default generic function will be created.
10:51:18
elderK
I'm in this weird position where I know what I want to build, and how I'll roughyl go about it - but I'm paralyzed because I'm not sure how to ... for the lack fo a better term, lay it out.
10:51:32
pfdietz
Some lisps give a style warning if you do defmethod on a symbol that hasn't been given a defgeneric. It's good style to do the defgeneric first, before defining any methods.
10:52:27
elderK
ogamita: I'm not sure how that helps. It's one thing to see the definition and stuff for things, it's quite another to learn how to apply them best.
10:54:35
elderK
It's like, another thing I'm unsure of, is like, it's say I have a "core" library. It has the barebones stuff on which to build.
10:56:17
elderK
I also find myself fighting... like, I want to give things nice, good names. But then, I also don't want them to be overly long since that's a PITA.
10:56:18
pfdietz
There is also something called package-inferred-system that infers system definitions from packages (with one defpackage per file). Some people like it, but it does lead to lots of packages being defined.
10:58:17
pfdietz
elderK: why don't you go look at some quicklisp systems, to see examples? There's a number of different styles in there.
10:58:52
elderK
God, it's crazy how languages can mess with your mind. You never realize just how much :) Like with C, I'm so... trained, I guess, to the idea of visually having a separation between public and private stuff, rather than just say, relying on being able to export certain things.