alcor` has quit [Remote host closed the connection]
alcor` has joined #commonlisp
Perflosopher has quit [Ping timeout: 252 seconds]
alcor has quit [Killed (NickServ (GHOST command used by alcor`!~user@2001:9e8:7ff:6800:5430:5b9:886b:f557))]
alcor` is now known as alcor
alcor has quit [Changing host]
alcor has joined #commonlisp
cage has quit [Remote host closed the connection]
Perflosopher has joined #commonlisp
alendvai__ has joined #commonlisp
attila_lendvai_ has quit [Ping timeout: 265 seconds]
mgl_ has quit [Ping timeout: 246 seconds]
dajole has quit [Quit: Connection closed for inactivity]
kevingal has joined #commonlisp
dino_tutter has joined #commonlisp
bitspook has quit [Read error: Connection reset by peer]
mwnaylor has quit [Ping timeout: 260 seconds]
bitspook has joined #commonlisp
alendvai__ is now known as attila_lendvai
cage has joined #commonlisp
cage has quit [Excess Flood]
cage has joined #commonlisp
amb007 has quit [Ping timeout: 272 seconds]
amb007 has joined #commonlisp
apac has joined #commonlisp
random-nick has joined #commonlisp
McParen has joined #commonlisp
<McParen>
hey #cl, are lisp strings defined "only" as types on top of character arrays or is there anything else that makes a string a string other than calling a character array a string?
<beach>
It's a vector (i.e., single dimension array) too.
<McParen>
yes but is there anything else to it? are "strings" really just a naming trick on top of arrays and a set of functions named "string-foo" to deal with those arrays?
<beach>
A string is defined to be a vector with an element type CHARACTER.
<beach>
Nothing else.
<McParen>
is it really that simple?? so if i wanted to define "my own extended string", i would just slap a deftype on top of vector with my character types and some functions and that would be it.
JuanDaugherty has joined #commonlisp
<beach>
I don't understand what kind of extension that type would have.
<McParen>
rendering. attributes, colors, etc.
<beach>
And I don't know what "slapping deftype on top of <something>" means.
<beach>
Your "character types" must be a subclass of the class CHARACTER, and you can't define a subclass of a system class.
<McParen>
i meant definint a "complex-string" type that would essentially be an array :element-type 'complex-char.
<beach>
And you can't create your own specialized array types either.
<beach>
An array like that would not be specialized.
<McParen>
it wouldnt need to be a subclass if I add a set of functions similar to string functions that would do the same thing.
<beach>
Oh, sure you can do that, but it won't be a string, and the array won't be specialized. It will just happen to contain the right types of elements.
<McParen>
and the only way to specialize would be wrapping it in a class?
puchacz has joined #commonlisp
<beach>
Wrapping something in a standard class would also not make it an array.
<beach>
But, sure, you can create a standard class and call it EXTENDED-STRING and define functions that operate on instances of that class, but it won't be a string, nor an array, and your "characters" won't be Common Lisp characters.
<McParen>
so.. what would be the most sensible way to have a "rendered string" that would also be an array like the normal string is?
<beach>
You can have an unspecialized array and just store whatever object you want in it.
<beach>
But it won't be a string.
<beach>
... and the objects you store in that array won't be characters.
<beach>
McParen: Maybe you don't understand the term "specialized array". It is not just an array where every element happens to be of a certain type. It is a subclass of ARRAY that has been created by the people creating the Common Lisp implementation, and instances of that subclass can not hold elements of any other type.
<beach>
McParen: So you can't store (say) 234 as an element of a string and thereby turning into something other than a string.
<McParen>
yes, i understand.
<beach>
So, a string is a specialized vector and it can hold only elements that are characters, that is elements that are (possibly indirect) instances of the system class CHARACTER.
<McParen>
so you basically cant straightforwardly have your own "extended string" containing "extended characters" and at the same time have it be an arrays and be able to specialize function arguments on it.
<McParen>
for a short moment i forgot that method args cant be specialized on types, only on classes.
<beach>
Even if you could, the functions in the "strings" dictionary are not defined to be generic, so you couldn't specialize any of them to your new type.
<beach>
And since your extended string is not a subclass of STRING, those functions won't work on instances of your extended string.
<beach>
Does all this make sense?
<McParen>
yes, absolutely, thatnks for the clarification. i had a small hope that i could avoid wrapping that array in a class, but i cant, since i want the extended string to be specialized upon.
<McParen>
what i can do is utilizing sbcl extensible seqeunces, and at least make that array wrapped in a class accessible to sequence functions.
<McParen>
then at least (length mystr), (subseq mystr) etc work.
random-nick has quit [Read error: Connection reset by peer]
<McParen>
again, thanks for your effort to clarify.
<beach>
Sure. Good luck!
apac has quit [Ping timeout: 252 seconds]
thuna` has quit [Ping timeout: 252 seconds]
cryptk has quit [Ping timeout: 245 seconds]
random-nick has joined #commonlisp
random-nick has quit [Remote host closed the connection]
cryptk has joined #commonlisp
cryptk has quit [Remote host closed the connection]
shawnw has quit [Ping timeout: 248 seconds]
rainthree has joined #commonlisp
szkl has quit [Quit: Connection closed for inactivity]
younder has quit [Remote host closed the connection]
brokkoli_origin has quit [Ping timeout: 260 seconds]
dnhester26 has joined #commonlisp
cmack has joined #commonlisp
<dnhester26>
does anyone know of a library to encode lists and hashtables or alists into x-www-form encoded form? quri takes in an alist, but the problem is that sometimes I need an alist embedded as a value to another a list, or in another case I need the value to be a list of alists, which doesn't work with quri
<dnhester26>
it's a fairly common use case to have a list of dictionaries as a value, usually they represent the keys like this "line_items[0][price]" and then some value
<dnhester26>
I can write it myself, but would like to avoid reinventing the wheel...
<beach>
What is "x-www-form encoded form"?
Everything has joined #commonlisp
wacki has quit [Read error: Connection reset by peer]
<beach>
I am afraid I don't understand the description of the problem at all. Maybe somebody else does.
<dnhester26>
it's ok, I'm just writing my own at this point, it's just faster
<dnhester26>
no worries, thanks for trying
<alcor>
Out of curiosity, why just not convert the hashtable to an alist before passing it to quri? It's not the most performant approach, but it should be good enough™ for a web application.
<dnhester26>
that's how I started, but the problem is that there are lists of alists embedded as values of the top alist and it breaks, quri needs to be just a simple alist where both the keys and the values are strings. Even integers as values gives an error, which is surprising
wacki has joined #commonlisp
<alcor>
I get it, so quri doesn't support nested structures.
<dnhester26>
exactly
<dnhester26>
is there a shortcut for (format nil "~A" value)? or a better form? should I be using one of the princ print or other function instead?
<beach>
dnhester26: Let me give you a short example here. If you have a call like (find ... :test #'eq :key #'car), this can be fairly inefficient. FIND needs to parse the keyword arguments, and then it needs to apply the TEST function and the KEY function to each element.
younder has joined #commonlisp
<beach>
A compiler macro can recognize that :test #'eq :key #'car were given, and turn the entire call into (find-with-test-eq-and-key-car ...) where find-with-test-eq-and-key-car can be a much faster function.
<beach>
In fact, many of the Constrictor compiler macros do something similar.
<dnhester26>
ahh, it's a macro for the compiler, not the "user"
<dnhester26>
we've talked about those before, got it, thanks
<beach>
Sure.
chomwitt has joined #commonlisp
<dnhester26>
ha, just had to write another loop over a hashtable, I'm glad I could find the example code in the technical reference hahahaha
JuanDaugherty has quit [Quit: JuanDaugherty]
apac has quit [Ping timeout: 246 seconds]
chomwitt has quit [Ping timeout: 260 seconds]
Gleefre has quit [Remote host closed the connection]
Gleefre has joined #commonlisp
<younder>
Iterate is a lot nicer than loop on hash-tables in particular..
apac has joined #commonlisp
McParen has left #commonlisp [#commonlisp]
<dnhester26>
alcor: i feel like regardless I'm not going to remember all the keywords since there are so many, so I will have to have a reference handy, and if that's the case, I may as well just use vanilla CL. Or do you find iterate so much easier to remember? like doing `for i from 0` was just another one I had to look up now...
apac has quit [Ping timeout: 252 seconds]
kevingal has quit [Remote host closed the connection]
bjorkintosh has quit [Quit: "Every day, computers are making people easier to use." David Temkin]
<alcor>
dnhester26: I think you meant to ping younder but tbh I usually prefer the vanilla CL solution since it's available on all CL systems and well-understood by all CLers.
<dnhester26>
oh my bad, sorry
<dnhester26>
hahaha
<dnhester26>
yeah, that was also part of my thinking, also why another dependency if it's not adding much
<beach>
Exactly. LOOP is fine for most situations.
apac has joined #commonlisp
ronald has joined #commonlisp
shawnw has joined #commonlisp
apac has quit [Ping timeout: 252 seconds]
Akbar-Birbal has left #commonlisp [Error from remote client]
Akbar-Birbal has joined #commonlisp
<NotThatRPG>
Dissenting view: the LOOP conditional syntax is so awful that it's worth the price of ITERATE.
<NotThatRPG>
Another reason is that I saw an absolute *TON* of code that just looked like this: (loop for x in <list> do ( ... enormous block of code with arbitrary stuff in it...) ) -- in practice I found that my co-workers were just using LOOP as a synonym for DOLIST...
<NotThatRPG>
Instead of using IF-THEN-ELSE, with its horrible syntax, they would just throw up their hands. At that point, well, "Loop Considered Harmful" ! ;-)
zxcvz has joined #commonlisp
zxcvz has quit [Client Quit]
Everything has quit [Quit: leaving]
dnhester26 has quit [Remote host closed the connection]
Catie has quit [Ping timeout: 260 seconds]
puchacz has quit [Ping timeout: 256 seconds]
oneeyedalien has joined #commonlisp
oneeyedalien has quit [Quit: Leaving]
chomwitt has joined #commonlisp
dnhester26 has joined #commonlisp
pranav has joined #commonlisp
jonatack has quit [Ping timeout: 252 seconds]
zenmov has quit [Ping timeout: 252 seconds]
k_hachig_ has joined #commonlisp
k_hachig_ is now known as k_hachig
dnhester26 has quit []
mountainman1312 has joined #commonlisp
jonatack has joined #commonlisp
zxcvz has joined #commonlisp
zxcvz has quit [Quit: zxcvz]
chomwitt has quit [Ping timeout: 245 seconds]
rainthree has quit [Ping timeout: 265 seconds]
spdegabrielle has joined #commonlisp
<NotThatRPG>
Is there any way to go from the stream created by `SB-BSD-SOCKETS:SOCKET-MAKE-STREAM` to the socket from which it was created? I'd like to be able to pull out port information, etc. from the stream but I don't see how to do this.
theruran has joined #commonlisp
mgl_ has joined #commonlisp
Posterdati has quit [Remote host closed the connection]
Posterdati has joined #commonlisp
rainthree has joined #commonlisp
Posterdati has quit [Read error: Connection reset by peer]
Posterdati has joined #commonlisp
mgl_ has quit [Ping timeout: 244 seconds]
<jackdaniel>
NotThatRPG: (apropos "FD") should yield something
<NotThatRPG>
@jackdaniel: I looked at the source code, but it seems that `socket-make-stream` just makes an FD stream and there's a little information in its name, but the socket is not attached (unless I'm misreading the code)
<jackdaniel>
re LOOP, there's also some very unintuitive fact, that the same variable is assigned, not bound, so it is easy to accidently capture mutated garbage
<jackdaniel>
NotThatRPG: fd is the socket
<jackdaniel>
socket descriptor to be precise
<dlowe>
jackdaniel: that's true for all the iterations
<dlowe>
iterative constructs, I should say
<jackdaniel>
dlowe: I don't have rwpl handy (on phone), but afair i.e dolist binds tge variable instead of changing its value repeatedly
<NotThatRPG>
oh! thanks! FD is nowhere described, so I assumed it was gonna be just an integer per "File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error conditions. "
<jackdaniel>
and other similar constructs of course
<dlowe>
I know I've gotten bitten by saving references this way but maybe only on loop
<dlowe>
NotThatRPG: you could try inspecting it with M-x slime-inspect or (inspect socket)
<jackdaniel>
on unix everything is a file, so for all practical purposes - a file descriptor (with tongue in cheek)
<NotThatRPG>
Thanks, @jackdaniel and dlowe ! I'll do some more groveling.
<jackdaniel>
good luck
dlowe has quit [Remote host closed the connection]
Akbar-Birbal has left #commonlisp [Error from remote client]
zwr has quit [Read error: Connection reset by peer]
<NotThatRPG>
One more SBCL streams question -- anyone know if there's example code out there anywhere that wraps an SBCL fd-stream in a gray stream? I'm still trying to deal with socket streams, and it's more likely I can figure out
<NotThatRPG>
how to glue a socket and an FD-stream together than that I can figure out all the internals of dealing with Unix stream descriptors.
<NotThatRPG>
I was thinking of making a gray stream subclass that contains the FD-stream and the socket object, so that I can just pull the information I want out of the socket object, where it's easy to get
<NotThatRPG>
Larry Wall says laziness is a programmer's virtue, so I was looking to see if someone else had written all the required code to delegate to a wrapped FD stream before doing it myself!
akoana has joined #commonlisp
<jackdaniel>
encapsulatin streamfrom clim ii?
<NotThatRPG>
@jackdaniel: Thanks! I'll look at that now!
chomwitt has joined #commonlisp
<gilberth>
Issue is that with SBCL the fd-streams don't implement the Gray stream protocol. So those encapsulated streams won't work.
<gilberth>
They just didn't feel like making builtin streams being Gray streams as well.
spdegabrielle has quit [Quit: Connection closed for inactivity]
<gilberth>
In CCL it would have been easier. Actually they already have a standard class, that just proxies to the underlying builtin stream object (what they call an IOBLOCK).
<NotThatRPG>
gilberth: Thanks. I guess I can just look at the existing encapsulating-streams code as a template for filling out the stream API instead of typing all of that by hand. Appreciate your saving me the trouble of finding that challenge myself!
<gilberth>
The encapsulating streams basically say something like (defmethod stream-foo ((stream encapsulated-stream) ...) (stream-foo (encapsulating-stream-original-stream stream) ...)). You would need to translate back from Gray streams to ANSI streams.
<gilberth>
Not that hard, just tedious.
Pixel_Outlaw has joined #commonlisp
bike has quit [Quit: leaving]
entro has quit [Quit: Quit]
entro has joined #commonlisp
mwnaylor has joined #commonlisp
JuanDaugherty has quit [Quit: JuanDaugherty]
Everything has joined #commonlisp
varjag has joined #commonlisp
pve has quit [Quit: leaving]
Gleefre has quit [Remote host closed the connection]
Gleefre has joined #commonlisp
k_hachig_ has quit [Ping timeout: 276 seconds]
cryptk has joined #commonlisp
mgl_ has quit [Ping timeout: 252 seconds]
Everything has quit [Ping timeout: 246 seconds]
wacki has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
amb007 has quit [Ping timeout: 252 seconds]
Everything has joined #commonlisp
amb007 has joined #commonlisp
zwr has quit [Read error: Connection reset by peer]
zwr has joined #commonlisp
amb007 has quit [Ping timeout: 264 seconds]
shawnw has quit [Ping timeout: 260 seconds]
attila_lendvai has quit [Ping timeout: 265 seconds]
alcor has quit [Remote host closed the connection]
livoreno has joined #commonlisp
pillton has joined #commonlisp
apac has quit [Ping timeout: 248 seconds]
chomwitt has quit [Ping timeout: 252 seconds]
dino_tutter has quit [Ping timeout: 265 seconds]
cryptk has quit [Remote host closed the connection]