freenode/#lisp - IRC Chatlog
Search
15:37:08
p_l
either I parsed XML differently in the past (lost source :( ) or I forgot how I specified dtd
15:39:11
p_l
had to download the dtd to home directory, but got this to pretty much output me a serialized form in S-expressions:
16:26:27
jgkamat
In case anyone was curious to my question yesterday, you need to have ps:lisp return a valid ps string, so (ps:lisp (push 'list my-list)) works for lists
17:31:39
p_l
my example included loading the DTD for apparently CXML didn't deal well with HTTP URIs in DTD specs
17:33:45
gjvc
yep got that and all working instaling into a project-local .quicklisp/ directory -- it's very neat
17:34:17
gjvc
i also have sbcl running via a bash wrapper to read the project-local sbcl initialisation file to make it take note of said project-local .quicklisp/ directory
17:39:05
gjvc
I have no interest in bootstrapping from them every run, given that the data is so simple
17:40:00
gjvc
but this is a more educational approach that just doing a big search and replace. (although i could write something in python to read the xml and emit lisp hmmm ...:-))
17:40:25
p_l
gjvc: then I think STP might offer a simple interface to rewrite them into whatever you want (it provides something akin to recursive descent where you plug your functions using STP methods to do things)
17:53:15
rumbler31
ok, I'm too dumb for this apparently. I want to generate and write a very long string to a file, constructed letter by letter. (dotimes (i large) (write #\E)) writes #\E, I am looking for the character itself to be read without the #\. Various attempts have failed. I suppose I could just use (format... but I'd like to learn what is going on here
17:54:31
rumbler31
assumption that was false is that I need to print pretty. that doesn't change the output unless I invoked it wrong
17:55:19
rumbler31
I assume that #\ is necessary for the reader to treat the form as a character and not a sybmol
17:57:00
pmai
FWIW write is very flexible, you can specify what you want using the keyword args or through the normal printer variables
17:57:52
rumbler31
write-char... of course. Also fwiw I was having a hard time understanding how the various flags to write relate to make thi shappen
18:38:02
p_l
Generally, for top-level variables: defvar, defparameter (the latter will always overwrite current value when evaluated), for constants use defconstant
18:38:34
p_l
mind you, defvar and defparameter will create dynamic variables, not lexical, but lexical top-level is a bit iffy
18:40:53
p_l
vms14: why do you need them in one form? It doesn't change things in the end, except for unexpected breakage from SETQ use
18:43:35
pjb
ggole_: (write foo :array t :base 10 :case :upcase :circle nil :escape nil :gensym t :length nil :level nil :lines nil :miser-width nil :pretty nil :radix nil :readably nil)
18:44:09
pjb
ggole_: of course, you can use ~A or ~S or princ or prin1 which pass the right key arguments to write.
18:45:37
p_l
vms14: because the general consensus was that assignment should not create new variables where there none
18:48:00
p_l
vms14: I tend to use DEFPARAMETER for things that I pre-set to some value, and include documentation on them (which it allows) which makes it simpler to understand the code the next day
18:48:47
p_l
i.e. it's much easier (IMO) to reason about a bunch of DEFVAR/DEFPARAMETER/DEFCONSTANT, especially when they include documentation, than any single SETQ anywhere in code
18:56:01
p_l
pjb: but the projects that insist on C either insist on it for the rare good reason (work on kernel code base in C) or can be safely ignored
18:56:27
p_l
projects that insist on language in my experience mostly involved corporate wanting java or similar :/
18:56:49
p_l
if you are the side signing the contract for the application, though, you can usually get any language going
18:57:42
p_l
vms14: and for good reasons implementations don't implement their own random object file linkers :)
18:58:03
p_l
(nothing stops you from doing one, though you would probably have to use less nice sides of FFI)
19:05:23
pjb
filename is already a pathname designator, you you don't need to call pathname on it, open will do it.
19:07:37
pjb
(with-open-file (stream filename :element-type '(unsigned-byte 8)) (cxml:parse stream handler))
19:13:27
_death
if filename is a string, then you likely want to use uiop:parse-native-namestring because otherwise each lisp implementation defines its own namestring format...
19:13:27
minion
_death, memo from flip214: I've got a couple of (old!) patches up at github.com/phmarek/dbus.git ... Would you please take a
19:18:47
pjb
vms14: (macroexpand-1 '(with-open-file (stream filename :element-type '(unsigned-byte 8)) (cxml:parse stream handler))) #| --> (let (#1=#:g37601 #2=#:g37602) (unwind-protect (multiple-value-prog1 (let ((stream (setq #1# (open filename :element-type '(unsigned-byte 8))))) (cxml:parse stream handler)) (setq #2# t)) (when #1# (close #1# :abort (null #2#))))) ; t |#
19:19:25
pjb
vms14: at home, try: (pprint (macroexpand-1 '(with-open-file (stream filename :element-type '(unsigned-byte 8)) (cxml:parse stream handler))))
19:27:36
vms14
I guess people usually don't mind in have features like what lisp offer and they look for something more mainstream
19:28:02
vms14
but when they have like 10 years of programming experience they'll be making complex systems
19:29:45
vms14
the problem is the programmer usually won't likely switch to lisp when he has 10+ years coding in somelanguage
19:33:31
LdBeth
It’s funny cause no other language use different implementations for development and deployment
19:35:12
vms14
(The bug was reported to SBCL maintainers, and there was a fix there as well, but we are still running with this hack, just to be sure :)
19:38:49
vms14
I think also we should make more documentation and maybe focus on noob friendly users
19:39:56
pjb
vms14: the essence of lisp is that you don't have a code syntax. The S-exp are defined to describe data.
19:40:01
vms14
for example the fact that python is one of the most recommended languages for a newcomer makes grow a lot its number of users
19:40:53
pjb
vms14: already, notice that there's no symbol data type in C to represent identifiers in data!
19:47:28
pjb
vms14: you still need symbols. Only Ruby has them, but with the awkward syntax of prefixing them with a colon.
19:50:19
aeth
vms14: Games probably have a better chance at being graphical applications using Lisp than traditional graphics applications because games don't have the expectation of native look and feel.
19:51:29
aeth
#lispgames is pretty active, and you have e.g. https://www.youtube.com/playlist?list=PL2VAYZE_4wRITJBv6saaKouj4sWSG1FcS
19:51:55
pjb
The essential feature is not homoiconity, it's to use the data syntax to represent code.
19:56:58
pjb
And you don't always need graphics: http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/sudoku-solver/index.html http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/rpsls/index.html http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/playtomo-stonedge/index.html
20:00:44
pjb
vms14: have a look at: https://cliki.net/Graphics%20library https://cliki.net/GUI I would advise https://cliki.net/pgl to write simple graphical games easily.
20:02:39
vms14
yeah, I had a look on what graphics libraries has cl, but ignored them because I know a bit of xlib, so I'd like to go for clx
20:06:41
vms14
but is nice to see this stuff, or at least to know that X was intended to be used mostly remotely
20:06:51
pjb
vms14: you don't need to know all of the condition system to use conditions. (handler-case (foo (error "an error occured")) (error (err) (print err))) is the basics of conditions.
20:06:58
Josh_2
yeh its all very annoying when you can just make a game using opengl where there are more tutorials than there are opengl programmers
20:07:18
_death
if you want to write xlib code, instead of writing a game you can have lisp play a game.. http://vito.sdf.org/dino.html
20:07:20
pjb
vms14: you don't need to know all of the format function to use format. (format stream "foo ~A bar ~S baz~%" a b) is the basics of format.
20:08:45
vms14
like appending to fill pointers, or iterating throught format arguments with things like ~:*
20:10:55
vms14
I don't know how to implement things yet, not meaning lisp, for programming in general
20:13:17
Josh_2
vms14: you just gotta find something you enjoy and just make stuff around that topic which I assume you are already doing
20:14:34
Josh_2
vms14: can you figure out how to send a button press event for me while you are at it xD
20:15:03
Josh_2
vms14: SBCL is very fast if you make declarations and use good datastructures etc, but clx is a cffi library basically so types are already known
20:49:34
jackdaniel
is there any rule in the standard how ratio should be converted to float wrt rounding? i.e is rounding to 0 correct?
21:49:30
pjb
You might want to compute the intersection of the shapes to remove it from the total area.
21:50:10
sjl
nai: ''nil reads as (quote (quote nil)), which evaluates to the list (quote nil). The cdr of that list is (nil).
21:52:52
sjl
It reads as a cons where the first element is the symbol programming and the second element is the cons itself, yeah
21:54:40
pjb
nai: it allows to create data structure where a substructure is referenced twice or more.
21:55:11
pjb
nai: in this case, we have #1# in the last cdr position, so it loops back to the first element, thus making a circular list.
21:55:24
_death
nai: https://gist.github.com/death/8c17afbba1eb10872e3c7f6f0bb7ba0a though it contains a bit of.. profanity..
21:55:45
pjb
So when printing, you get an infinite list of programmable programmable programmable … programmable programming language.
21:55:47
LdBeth
Interestingly, dispatch macro accepts a numeric arg but only a few utilizations of it
21:56:38
nai
i started trying to read LoL yesterday but then i realised my knowledge of lisp was wayyy insufficient. so here i am learning basic lisp
21:56:57
pjb
## and #= can be used to all kinds of data structure, as long as they have a readable syntax.
22:01:53
sjl
I have *print-level* and *print-length* set to big-but-finite values in my init files to prevent accidents
22:02:20
nai
i was looking at "big-but-finite" for a second like it was a lisp special value or something
22:02:44
pjb
(maplist (lambda (x) (cons x (car x))) '(a b c d e f)) #| --> (((a . #1=(b . #2=(c . #3=(d . #4=(e . #5=(f)))))) . a) (#1# . b) (#2# . c) (#3# . d) (#4# . e) (#5# . f)) |#
22:03:17
pjb
nai: because code must not contain circularity (and even shared structures). Only data (including literal data, as quoted) can have them.
22:03:54
pjb
The behavior of #1=#(#1#) may be surprising: the implementation could choose to send a missile in the general direction of your house.
22:10:22
sjl
> [special case about load-time-value described] This can happen both when an expression being evaluated or compiled shares substructure,
22:11:08
sjl
Seems to point at sharing substructure being okay. Can you be more specific about where the standard prohibits it?
22:15:00
pjb
There may be other problems, such as if the implementation provides source location, associating it with the lisp object. If it's shared, it can look as if the same lisp object has several source locations, but the implementation may be not prepared to deal with that case.
22:17:02
nai
+ seems to be the last thing i typed, * the last result i got, / the last result wrapped in ()
22:31:08
aeth
_death: At that point, just use LOOP or write your own macro on top of DO (I've done both) to avoid the repetition of the read
22:59:48
loli
It has been fun hacking package(module) functors into CL, the package system isn't the greatest so it has been a pain to do, but you can get some decent results
23:01:11
aeth
_death: imo it's a flaw in the code to use reader features when a defmacro can work instead
23:06:15
_death
aeth: the expansion of TWICE with a cons form also demonstrates structure sharing in code.. if you mean to discuss the style aspect of the DO idiom, I would tend to agree
23:10:31
_death
in your .emacs you can then have something like (setq common-lisp-hyperspec-root "file:///home/death/dev/HyperSpec/")
23:13:03
aeth
_death: I have only ever seen #1# etc. actually used in things when *print-circle* was T
23:16:27
aeth
And in that example you can't even print it without print-circle because it quickly becomes too large (not sure if 9 does it or if more are needed)
23:16:58
Bike
"here's some code that does x" is kind of a weird way to try to make the point that you shouldn't write code that does y
23:17:23
aeth
Bike: my point is that *print-circle* is the only time I've seen that feature used well
23:18:55
aeth
but it's not hard to read in my example, the alternative is either hard to read or impossible to print, depending on how long you iterate
23:19:28
Bike
your example doesn't use ## syntax. i'm saying if you want to argue not to use ## syntax in code, you should do that, and not talk about something very nearly unrelated
23:19:48
aeth
_death: I absolutely disagree with verisimilitudes's style on just about everything. Lots of obscure niche features I've never seen in other code (I've read a lot) e.g. &aux
23:20:02
aeth
_death: But then again I heavily use custom macros in my game engine so it's kind of like throwing stones in glass houses
23:21:15
aeth
Bike: it's in the print, it prints as this but on multiple lines for me: #(NIL #1=(NIL) #2=(NIL #1#) #3=(#1# NIL #2#) #4=(#2# NIL #1# #3#) #5=(#3# #1# NIL #2# #4#) #6=(#4# #2# NIL #1# #3# #5#) #7=(#5# #3# #1# NIL #2# #4# #6#) #8=(#6# #4# #2# NIL #1# #3# #5# #7#) (#7# #5# #3# #1# NIL #2# #4# #6# #8#))
23:21:59
Bike
i'm telling you that printing an object with shared substructure is pretty much unrelated to writing code using ##
23:22:41
aeth
Bike: I'm saying that priting an object (or perhaps even writing a literal object) with shared substructure is the correct use of this feature, and writing code using it is abuse of this feature
23:23:09
_death
personally I think his external interfaces are good, and the implementation is simple enough, so don't mind the eccentricities
23:24:23
aeth
I wouldn't permit it in one of my projects, but I obviously don't have the authority to ban it everywhere. Style is subjective.
23:24:23
_death
gjvc: I use emacs-w3m (er.. nowadays eww actually, I guess) to view it, so don't care about css
23:24:52
aeth
_death: Imo, I don't like code I can't easily read in libraries I use because when something goes wrong the first thing I do is M-.
23:25:42
aeth
_death: That, of course, means that I wouldn't use my own game engine if someone else had written it, but I guess that's why I'm writing my own.
23:29:18
aeth
_death: I've definitely had my share of losing a day (or more) on trying to read someone else's code (and mine as well, but that's my fault), usually when it uses macros that are far too clever.
23:33:18
_death
aeth: every abstraction has a cost.. good taste requires appreciating this cost vs. the value provided
23:35:10
aeth
_death: Personally, I find that layers of macros greatly simplifies things assuming M-.
23:36:27
aeth
_death: e.g. if you're inlining functions a lot in macros, use a macro that can do (progn (declaim (inline foo)) (defun foo (...) ...)) and now you've just greatly simplified all the macros that generate inline functions by getting rid of that complexity, and the double-use of the function name
23:37:10
aeth
Then once you're familiar with that (e.g. through M-.) the actual source of the other macros are much simpler
23:42:45
aeth
nai: Imo it's easier to jump to several definitions and keep things broken up into small pieces then to try to parse the logic of a 150-line macro
23:43:03
aeth
M-. will take you to the definition in Emacs+SLIME, other IDEs may have another way to do that
0:26:26
catchme
If anyone interested: Common Lisp and CXX interoperation with c++ meta programming c++14
0:30:02
no-defun-allowed
"tax forms are to poetry as C++ metaprogramming is to Lisp macros" quoting drmeister from memory
0:30:48
no-defun-allowed
so it generates a CL package with C++ functions from a specially setup C++ library?