freenode/#lisp - IRC Chatlog
Search
18:32:46
rumbler31
jmercouris: You already type things like, (make-array dims :initial-contents '(a b c ...)) So if you take an array and splat its contents into a string, you can re-make this form
18:33:40
rumbler31
serialize becomes taking the contents of an array and generating the string "(make-array size :initial-contents '(real contents here))" and then calling read on the string, right?
18:35:30
_death
I'd rather communicate via json.. read-from-string is definitely not a good way to communicate with the outside world
18:38:05
pjb
incompatible float formats, bignums not supported (eg. in C), confusion between lists and vectors, a-list and hash-tables, etc.
18:38:45
_death
still you need to trust the other side, and then there's the matter of interning (which you can simplify by using keywords everywhere...) and more..
18:38:59
pjb
Not all lisp objects have a printable readably form, but at least, it's specified. (cf. chapter 2).
18:55:33
jackdaniel
sxhash isn't necessarily used in hash tables. also it is not necessarily based on address (consider moving gc)
18:56:28
pjb
For example, you could have a CL implementation that would use wool threads and a robot to tie knots in them to build cons structures.
18:58:36
jackdaniel
pjb: I'm referring to internal ECL implementation, it is in context of mentioning si:pointer
18:59:14
_death
jackdaniel: speaking of ecl, do you have any input on the two "wtfs" I mention in https://github.com/death/TIC-80 .. I didn't get to looking further into them
18:59:43
pjb
jackdaniel: well, if you're based on C, it is disputable that addresses exist. In C you have pointers (opaque) and integers, and a way to convert from one to the other, but nothing implies that integers are related to eg. a MC68000 address.
19:00:23
pjb
shka: hint: hash values are only useful for one thing, in general you are not needing them.
19:01:37
jackdaniel
_death: as of second wtf – I can help with that, but you won't have ability to load native fasls (something I plan to work on though)
19:02:06
jackdaniel
as of first wtf, I think that calling cl_shutdown and after that cl_boot should be enough
19:02:24
pjb
shka: indeed, sxhash is defined in terms of similarity which for cons cells defer to the similarity of car and cdr.
19:03:12
_death
jackdaniel: I think that's what is happening, but it's not enough.. I think something akin to lua_State would be great, but that's likely too much of a big change
19:03:15
pjb
shka: There is no conforming way to get the identity of a cons cell otherwise than the cons cell itself. And also, similarity is defined cross images!
19:03:37
shka
there is a couple of singular lists, the rest is constructed by consing into other list already existing in the table
19:04:02
jackdaniel
_death: I would have to look into it, but right now I have work in progress on delimited continuations + green threads in ECL, so that would have to wait
19:05:03
jackdaniel
if you could report issue on gitlab with description what lua_state is and what you are expecting, that would be great
19:05:47
shka
but this allows me to (when i have reference to the right list) to obtain value from hashtable, as well as do the same for every rest
19:09:52
shka
i am under impression that "[20:02] <pjb> shka: indeed, sxhash is defined in terms of similarity which for cons cells defer to the similarity of car and cdr.", which translates into recursive definition of hash
19:11:43
pjb
Well, then you will have to use a CL hash-table to map cons cells to unique identifiers that you can use in your own hash function.
19:12:10
pjb
Perhaps some implementations let you find the address of a cons cell (but as noted, if they have a moving GC, the address will change).
19:12:23
pjb
clisp can be compiled to provide a third slot to each cons in which you could store a unique identifier.
19:13:17
pjb
Notice also, that for hash-table with equal or equalp most implementations won't compute the hash on all the elements of the list, but use a projection such as list length, hash of the first and last element.
19:14:56
pjb
Or imagine an implementation storing cons cells by drawing them on paper, and following the links with a camera: https://www.youtube.com/watch?v=Mp8Y2yjV4fU
19:17:00
pjb
sometimes, you can use a (defstruct kons car cdr key something-else) and build your lists (copy CL lists) using that.
19:22:52
pjb
so you build a spinal cord: (defstruct box cons key) (let ((k 0)) (maplist (lambda (c) (make-box :cons c :key (incf k))) '(1 2 3))) #| --> (#S(box :cons (1 . #1=(2 . #2=(3))) :key 1) #S(box :cons #1# :key 2) #S(box :cons #2# :key 3)) |#
20:55:16
rumbler31
pjb: in your example output, does the #1= and #2= mean that subsequent uses of #1# and #2# refer to eql cons's, not just identical in contents?
21:01:17
dwts
Hey guys, does anyone know why the first part of the code works while the second one doesn't?: https://codepaste.net/gisfzt
21:33:41
Bike
dwts: yeah looks like the general use is for the values to be strings. `word` there is of course a symbol, not a string.
21:34:58
Bike
there's a function, but in this case i imagine the problem is that you're not actually using a variable.
21:41:14
Bike
it's not that important. instead of the compiler, you have me telling you you made a mistake. artificial artificial intelligence, it's called
21:41:45
Bike
you understand, right? you quoted `word`, so it's not evaluated, so the argument isn't used, drakma only sees the actual symbol WORD
21:45:40
dwts
Bike: yep, that did the trick! Also type-of looks helpful if you are unsure what you are passing to your functions I guess
22:58:11
mrottenkolber
spreadable argument list designator n.: a designator for a list of objects; that is, an object that denotes a list and that is a non-null list L1 of length n, whose last element is a list L2 of length m (denoting a list L3 of length m+n-1 whose elements are L1i for i < n-1 followed by L2j for j < m). “The list (1 2 (3 4 5)) is a spreadable argument list designator for the list (1 2 3 4 5).”
22:59:33
mrottenkolber
so if a spreadable argument list designator is a “non-null list L1”, that means nil is not a valid s a l d, right?
23:06:19
mrottenkolber
I seems to indicate that (apply 'list '(1 2 3 (4 5))) ≡ (apply 'list '(1 2 3 4 5)) which is luckily not true on i.e. CCL
23:11:58
mrottenkolber
the + led me to believe apply would accept one or more spreadable argument list designators
23:14:25
pjb
mrottenkolber: but you have to remember that &rest gets a list of arguments, so when the spreadable argument list designator takes for example (1 2 (3 4 5)) it means that the function was called with the rest arguments 1 2 (3 4 5) like this: (apply 'list 1 2 '(3 4 5)) for example
23:51:29
k-stz
is there a protable way to translate a c array to a lisp array, or can I just leave it in its cffi SAP form? Efficiency actually matters in this case
23:57:48
k-stz
I'm not sure what counts as keeping it around. As its set up to be I have to use it multiple times. I'd have to test it
23:58:21
pjb
But remember that you have to free C data yourself (unless you use a underlying C garbage collector such as the BoehmGC.
23:58:41
pjb
k-stz: if you only need to access the elements of the C array once, there's no point in copying it.
0:02:47
pjb
You may want to optimize safety and ease of use; lisp data is easier to use than foreign data.
0:04:01
dwts
mrottenkolber: is there an alternative that returns same results across implementations?
0:06:01
k-stz
But also the idea to make a lisp-array from pointer data sounded mildly exciting ;), so I thought it made by even a common thing to do!
0:06:44
pjb
It's only that it's slow. So you need to be able to amortize it, if your purpose is to optimize execution speed.
0:07:13
Bike
it basically amounts to making a lisp array of the length of the c array and copying the c array contents (translating as you go)
0:07:58
mfiano
dwts: The author of Common Lisp Recipes gives an example, `(type-of "foo")`, giving 4 different results across 6 different implementations. To be portable, you probably want to check for an explicit type/subtype with TYPEP/SUBTYPEP, or perhaps someone more familiar can give more help.
0:09:08
k-stz
Bike well just have lisp use the exact addresses pointed to, not freshly allocate an array
0:09:30
Bike
but it's a c array. lisp arrays have type information and stuff. and can be garbage collected.
0:13:03
dwts
I was wondering, is anyone here using common lisp at work? I've only used scheme (in the past) common lisp (now) for some toy projects
0:16:52
dwts
Xach: Given that there aren't many (to my knowledge) common lisp positions, how many years of experience one would require to get a senior common lisp position?
0:20:19
Xach
There are CL projects in many companies, but they are not often made public. They are often the work of enthusiastic individuals who really want to use Common Lisp and have some discretion at work. That might be because they are founders or just given a lot of independence.
0:22:19
Xach
Before I did contract CL work, I used CL to write tools to make life easier in various ways - to process or generate data, or to generate code for tools in other languages.
0:22:20
dwts
Yeah, I've noticed that you can't get much info on that subject. Apart from a few companies that were using common lisp and then turned to python/whatever it's really hard to get any info
0:24:32
Xach
dwts: rob warnock has written quite a bit on the topic. he uses the CL pretty-printer in nice ways to generate code.
0:27:13
Xach
here's a small bit: https://www.xach.com/rpw3/articles/mbudnVpUvZKbC8XVnZ2dnUVZ_vudnZ2d%40speakeasy.net.html
0:28:58
dwts
Xach: this kind of info make lisp's power look unlimited...or only limited to one's imagination
0:39:56
mejja
(format t "~%foo_t ~a_foos[~d] = {~ ~%~{~<~%~1,68:; {~/0x/, ~2/0x/}~>~^,~}~%};~%" instance (/ (length data) 2) data))
0:42:28
dwts
Xach: how feasible do you think it would be to write a linter in common-lisp? I was thinking about a chef linter
0:43:45
pjb
Very feasible: https://www.google.fr/search?client=safari&rls=en&q=common+lisp+lint&ie=UTF-8&oe=UTF-8&gfe_rd=cr&dcr=0&ei=qHYTWq3jGrGJgAborLiQAQ
0:46:02
aeth
mejja: format takes in streams, so you can break it up into smaller parts and even mix non-format writing/printing things in as well
0:46:53
aeth
(only format nil would make this hard, but you could use with-output-to-string instead to generate a string that way)
0:49:53
aeth
mejja: Here's an example (but, of course, this is a toy example and I wouldn't break this up): (progn (format t "Hello, ") (format t "world!"))
0:51:24
mejja
code snippet is from the link pasted by Xarch a page up. original author is Rob Warnock not me..
0:55:46
aeth
mejja: if it ran (it doesn't!) and if Lisp Paste was still up, I'd try to make it more readable
1:00:19
aeth
If you want to see a completely different approach to generating C-style syntax, I generate a subset of GLSL (which uses C-style syntax) recursively here: https://gitlab.com/zombie-raptor/zombie-raptor/blob/79ba7be2b51ca8992c453490fb9a7bb109027818/data/generate-glsl.lisp
1:03:05
aeth
It's not very efficient because it recursively returns strings generated by format nil, but it runs while compiling to produce constant strings so I don't really care about performance. If I had to write it today, I might consider a with-output-to-string stream instead of returning and concatenating strings.
3:49:04
mfiano
just ask your question, and understand that 'clisp' refers to an implementation, and not common lisp the language
3:51:23
internet_cafe
ok, i have a list like (('a' 1) ('b' 2) ('c' 3)), is there a way to get 3 by looking up 'c' ?
3:53:58
pjb
internet_cafe: (let ((list (quote (('a' 1) ('b' 2) ('c' 3))))) (cadadr (assoc 'c list :key (function cadr)))) #| --> 3 |#
3:55:53
pjb
internet_cafe: read https://sourceforge.net/p/clisp/clisp/ci/tip/tree/doc/LISP-tutorial.txt
3:56:15
pjb
internet_cafe: if you want more: Common Lisp: A Gentle Introduction to Symbolic Computation http://www.cs.cmu.edu/~dst/LispBook/ http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html
4:01:20
pjb
internet_cafe: if you read a tutorial, you'd know that 'x is equivalent to (quote x) and quote is a symbol just like any other.
4:10:13
pjb
You will have to use the :test option, since in general, you don't keep references to the string used as keys…
4:12:38
pjb
internet_cafe: one advantage of lisp is also one inconvenient. Since it's written using syntax for data, almost all forms are valid. As data of course, but also as lisp source, since you can always interpret any lisp data as lisp code. At worst, it will signal an error (and this may be what you want, who are we to say otherwise?).
4:13:09
pjb
internet_cafe: the big advantage from this is that it gives the programmer great freedom to transform the code as you wish, and to process it very easily thru functions and macros.
4:14:19
pjb
There are still some texts you cannot read as lisp data. For example if you have unbalanced | or if you have multiple dots in lists or vectors, things like that.
4:14:28
pjb
(foo|bar) #| ERROR: Unexpected end of file on #<string-input-stream :closed #x302008CDECCD> |#
4:14:36
pjb
(foo . bar . baz) #| ERROR: Reader error on #<string-input-stream :closed #x302008CFECCD>: Dot context error in ".". |#
4:15:11
pjb
(foo ') #| ERROR: Reader error on #<string-input-stream :closed #x302008C5ECCD>: Unmatched ')' . |#
4:16:27
pjb
More than 2 colons too, depending on the implementation: (quote cl-user:::bar) #| --> \:BAR |# but ccl accepts it.