freenode/#lisp - IRC Chatlog
Search
18:42:30
pjb
paule32: type (apropos "TOPOLOGICAL-SORT") this should show you what package it comes from.
18:43:24
pjb
paule32: obviously you cannot remove it, it's an important part of the algorithm. Instead, you can try to design a different algorithm to evaluate a circuit.
18:47:41
pjb
This imports all the usual packages from the com.informatimago, so my functions are available.
18:48:21
pjb
(actually, I do that in a com.informatimago.pjb package, and I just use it in cl-user and others.
19:06:47
pjb
paule32: in the mean time you can just remove com.informatimago.tools.manifest from the systems to load.
19:26:04
pjb
paule32: why would you expect output from loading a lisp source file, and then QUITTING!?
19:30:05
mgsk
Is it possible to do something like (defun something (&key a b &rest c) ...) where in (something :a 1 :b 2 :c 1 2 3) they keyword :c "collects" all remaining forms, i.e. C = (1 2 3)?
19:31:50
Xach
What actually happens is that the &rest var collects subsequent keyword/value pairs. but they have to be matched.
19:32:57
Xach
(defun make-a-thing (class-name &rest args &key &allow-other-keys) (apply 'make-instance class-name args)) for a dumb example
19:35:27
mgsk
I was just thinking about how use-package (in emacs) allows for arbitrarily many forms to be given to a keyword (until the next keyword). But rather than complicate things, I'll re-think my design
19:47:28
pjb
paule32: why does it quit in the end? You're doing it wrong! Never quit from a lisp image!
19:52:36
pjb
mgsk: for example, something like (let ((arguments '(:a 1 :b 2 3 4 5 6))) (destructuring-bind (&key a b c) (loop with expected = '(:a :b) while (and arguments (cdr arguments) (member (first arguments) expected)) collect (pop arguments) into keys collect (pop arguments) into keys finally (return (list* :c arguments keys))) (list :a a :b b :c c))) #| --> (:a 1 :b 2 :c (3 4 5 6)) |#
19:55:46
pjb
mgsk: so (defun foo (&rest arguments) (destructuring-bind (&key a b c) (loop with expected = '(:a :b) while (and arguments (cdr arguments) (member (first arguments) expected)) collect (pop arguments) into keys collect (pop arguments) into keys finally (return (list* :c arguments keys))) (list :a a :b b :c c)))
20:44:31
phoe
paule32: using Lisp without slime is a terrible experience. you might as well be using a non-interactive language like C or Java.
20:46:02
phoe
doesn't matter what Java is. coding in Lisp without any kind of interactivity layer for it prevents you from taking advantage of one of its most important features.
20:51:34
paule32
pjb: $ clisp elo.lisp # in elo.lisp: (load "./init.lisp") ; where your code from paste
20:57:55
pjb
paule32: well, perhaps you don't have a clean cl-user package. Of course, I've already explained years ago, that one should clean his cl-user package in the rc files…
21:00:22
pjb
paule32: then add (load (merge-pathnames (make-pathname :directory '(:relative "RC") :name "COMMON" :type "LISP" :case :common) (user-homedir-pathname) nil)) in your ~/.clisprc.lisp file.
21:00:34
aeth
Would it be possible to write something that automatically recompiles all users of a macro, struct, inline function, etc., when it is recompiled? Basically, all of the stuff that can go stale.
21:01:03
aeth
(structs doing this, of course, is implementation-specific, but it would have to be done to be portable, and to support SBCL)
21:01:21
phoe
Write a custom DEFUN/DEFMETHOD/DEFeverything that codewalks the forms and finds all uses for the macro in question.
21:01:44
pjb
aeth: have a lookt at: Image Based Development http://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/ibcl/index.html
21:01:57
phoe
Then write a custom DEFMACRO that, whenever a macro is recompiled, finds all users of that macro stored via the above forms, and recompiles them.
21:02:15
aeth
phoe: I was hoping that there was an easier way. SLIME and/or ASDF probably already know certain things.
21:02:33
pjb
aeth: this way you can save the source of each form; you may add a plist to macros, structures, inline functions, etc, to list all the things that need to be recompiled.
21:02:53
Bike
i don't think they implementations actually usually track macro usage, just function usage, which they need to know for linking purposes
21:06:19
aeth
What has issues with recompiling, btw? I'm aware of inline functions, macros, and sometimes (afaik it's implementation-specific) structs.
21:07:53
aeth
I think package definitions also have issues, but only if you remove things (rather than add things)
21:08:07
aeth
But you can remove those manually by going into the package and uninterning manually iirc
21:09:05
Bike
depending on how you construe the workings of load-time-value in relation to compilation, maybe you'd need to recompile for lots of random reasons
21:09:33
Bike
strictly speaking, some properties of classes, though i don't know if any implementation actually takes advantage
21:09:37
aeth
Oh, actually, I never have to do the whole in-package thing for uninterning ever again, in implementations that support foo::(unintern 'whatever)
21:13:31
aeth
the syntax is: (unintern 'foo::some-symbol-to-remove :foo) because I need to tell it to remove the 'some-symbol-to-remove that's in foo
21:16:19
aeth
Anyway, my actual point was: if I recompile a function without recompiling the defpackage that imports the new symbol (oops), I now need to unintern that symbol before recompiling the defpackage or else there's a conflict that the debugger wants me to resolve.
21:18:12
Xach
You get "undefined function frob" and you change defpackage to :use the package that provides frob and you get a conflict?
21:18:25
Xach
That happens to me - when it does, I use shadowing-import-from to clobber the existing one.
21:23:37
pjb
paule32: great. so now you can load your code; it would be nice to define your own package for it. Then you can use the com.informatimago.common-lisp.cesarum.utility package.
21:24:25
pjb
paule32: so after you've loaded the file, you can go on programming, testing, and debugging.
21:25:08
pjb
paule32: I don't know how many years ago you've started with lisp: you've made clearly no progress since that day. This is because you don't use the REPL.
21:25:22
paule32
pjb: hehe :-) but it is a little bit boring always to load clisp and type (load foo.lisp)
21:25:31
pjb
paule32: so start using the REPL, at least in the terminal (with clisp it's liveable since there's readline). Better with slime.
21:25:53
pjb
paule32: you don't always load clisp: you load it once when you boot your computer and that's it.
21:26:46
aeth
paule32: pjb is 100% correct. The proper way to learn CL is to think up small test cases and see how they evaluate in the REPL, preferably the SLIME (or similar) REPL so you can also interact with existing source files.
21:27:06
pjb
paule32: you don't type (load "foo.lisp"). In a project, you create a loader.lisp file that will load it, and you type: ll RET at the REPL, with my command.
21:28:41
pjb
and since you always have clisp running, you don't need a shell anymore. You can close your other terminal windows, and use clash to run shell commands: https://clisp.sourceforge.io/clash.html
21:30:00
pjb
with clash and readline, you type Meta-c unix-command RET in the REPL to run unix-command.
21:31:06
paule32
pjb: the problem: i can't use cursor-up: i expect the last typed command line, but [[A comes
21:32:24
aeth
If you want to launch programs from the REPL, you can use uiop:launch-program (asynchronous) or uiop:run-program (synchronous)
21:32:41
aeth
(Note: launch-program is a newer feature, so you probably have to Quickload UIOP first.)
21:35:49
paule32
amd i wonder, why the compiled system run so fast - in fact, the fasl's are ascii text file's
21:36:01
pjb
paule32: also, see the call to print-state and uncomment it (comment out the following form instead).
21:41:11
pjb
paule32: clisp --version|grep -e '^libreadline' # should indicate the version of the readline library that is linked.
21:42:51
pjb
paule32: so to obtain the binary, you need to compile the source file. Unfortunately, with clisp, the debugger is way less effcient on compiled code than on interpreted code. So if you want to debug on compiled code, you should rather use ccl (or sbcl).
21:43:09
pjb
paule32: in any case, the advantage of using slime, is that you have the same debugger for all the supported implementations! sldb.
22:14:43
pjb
ebrasca: a good test to see if it's good, is to ask a student to make a modification or improvement to it, and see how easy he can do it.
22:17:47
aeth
Start a new Blockchain-based university and become the anonymous leader of that university. Qualifications are so 20th century.
22:22:48
aeth
pjb made a contribution to one of my projects once. trivial-left-pad, one of my first of April projects.
23:25:24
asarch
Hey guys, how would you open a big file, parse its content line by line and print the third column of every line that matches with a regexp?
0:20:07
Xach
didi: sorry not to have a useful answer - it would be nice if there was a library for your task. but it seems pretty complicated and i don't know of one.
0:24:00
didi
Xach: Nothing in particular. Just thought of it and realized I couldn't go earlier than 1900.
0:24:24
Xach
then perhaps investing in the great book "Calendrical Calculations" is not worth the trouble
0:29:24
Bike
i continually get confused reading mildly old russian things and being unable to comprehend julian dates
1:33:38
pjb
ym: the real world is part of the program: the universe is obviously a simulation written in your FP program!
1:35:41
asarch
Sorry if I insist. I promise this would be my last question but, how would you open a big file, parse its content line by line and print the third column of every line that matches with a regexp?
1:37:04
pjb
asarch: (with-open-file (stream "big-file") (loop for line = (read-line stream nil nil) while line when (regexp-match-line-p regexp line) do (print (third-column line))))
1:41:37
asarch
Actually, in the sed time I was looking for a decent programming language with OOP support
1:46:50
pjb
asarch: you may try: printf '((' ; psql --tuples-only --dbname="$DB" --user="$USER" --no-align --field-separator=')(' --record-separator='))'$'\n''((' --command="$QUERY" ; printf '))\n'
1:47:11
pjb
asarch: or rather: printf '(' ; psql --tuples-only --dbname="$DB" --user="$USER" --no-align --field-separator=')(' --record-separator='))'$'\n''((' --command="$QUERY" ; printf ')\n' # since it's big.
1:48:39
pjb
or perhaps: printf '("' ; psql --tuples-only --dbname="$DB" --user="$USER" --no-align --field-separator='")("' --record-separator='"))'$'\n''(("' --command="$QUERY" ; printf ')\n' # you may also have to modify the readtable, in either case, if any field contains double quotes or stuff…
1:50:14
pjb
asarch: you may also just use --html, and then parse the HTML. It may be safer, if psql escapes correctly < and > in the fields.
1:58:14
pjb
asarch: unfortunately, nowadays things are more complex. Youngsters can't respect nice conventions, such as writing a unix manual page. Instead, then write info page sometimes, or --help option to their commands.
2:01:01
asarch
For example, when I was learning Python I asked about how to put two commands in a single line
2:01:37
asarch
Since Python actually gets rid of the semi-colon punctuation mark to end a command just like Perl or C/C++ do
2:06:25
aeth
The only thing you need to know is man unless it's a GNU project, in which case the man just tells you to use info for the real information.
2:07:03
aeth
e.g. "The primary documentation of GNU Emacs is in the GNU Emacs Manual, which you can read using Info, either from Emacs or as a standalone program. Please look there for complete and up-to-date documentation. This man page is updated only when someone volunteers to do so."
2:10:22
aeth
Oh, great, the newest Firefox (48?) or something else seems to have no audio in StumpWM. Is anyone else getting this? It tells me to install PulseAudio, which is nonsense because (1) everything else still has sound and (2) Firefox on other desktops like KDE still has sound.
2:19:39
aeth
Looks like I now need to enable pulseaudio via systemd, even though I have never needed to do that before.
2:22:31
aeth
What's particularly strange is that the change in Firefox happened 6 versions ago but I'm only having the problem now.
2:29:39
aeth
Technically, I think it *is* a flaw in stumpwm because KDE has some way of working around this without me having to do something. I guess I can take it to the stumpwm channel, though.
2:30:55
didi
aeth: StumpWM is just a Window Manager. KDE is a whole desktop environment. They aren't comparable.
2:34:34
didi
Every time I use `multiple-value-bind' and I don't care about some variables, I dream of writing a macro that would discard NIL variables.
2:38:25
aeth
didi: Imo, they are comparable. The main difference is the lack of a StumpWM suite of applications (which means having to use a terminal, graphical file manager, etc., intended for a different desktop environment)
2:39:54
Bike
the point here would be that stumpwm doesn't have some DE workaround deal, since it just displays windows
2:41:30
didi
aeth: Taking your problem as an example, StumpWM knows nothing about sound, only windows. If you are running some kind of sound server, it wasn't StumpWM that started it.
3:33:12
whoman
other than symbols; paredit to working with lisp in emacs is what macros are to lisp, lets say
3:33:30
pjb
iqubic: as a lisp beginner, I would 1- use the CL implementation in a terminal during 2 days. 2- use the CL implementation in emacs (without slime) during 2 days. 3- use the CL implementation in emacs with slime during 2 days. and finally 4 use CL in emacs with slime and paredit for the rest of my life.
3:35:26
whoman
wrapping/unwrapping and moving left and right parens, are very nice features of paredit
3:45:33
Colleen
beach: drmeister said 8 hours, 22 minutes ago: Above I dumped the environment from within convert-elementary-setq (stored in cleavir-cst-to-ast::*debug-env*)
3:45:33
Colleen
beach: drmeister said 8 hours, 21 minutes ago: This is the environment when compiling one of the PUSH macros in this macro... https://github.com/drmeister/clasp/blob/cst/src/lisp/kernel/lsp/defmacro.lsp#L95 There is no mention of special-variable entries - so I think something is wrong with how the environment is being put together.
3:59:17
ghostyyy
hi, i have heard a lot about lisp macros, does anyone know any useful and practical examples of their usage?
3:59:57
ghostyyy
i googled it but i just get people talking about why macros are cool, ajnd not a lot of practical examples
4:01:25
ghostyyy
oh, i see! are clisp macros different from hygenic scheme macros in any appreciable way? i dont know clisp well, only scheme
4:01:33
beach
ghostyyy: Basically, macros allow the programmer to introduce syntactic abstractions, thereby making it possible to cut down on a lot of boilerplate code.
4:02:45
beach
ghostyyy: Common Lisp macros have the full language at their disposal in order to transform a form to a different form.
4:05:02
Bike
common lisp macros are much simpler. a macro is just a function that you call on source forms, that return macroexpanded forms.
4:05:17
beach
ghostyyy: For someone who doesn't know what macros are for, you seem to know a lot about them.
4:06:32
ghostyyy
i have studied them a bit but i only get academic examples about how to define "cond" fifteen different times a la https://www.cs.indiana.edu/~dyb/pubs/tr356.pdf
4:06:38
Bike
the downside to simpler is that you have to think about actual symbols and worry about a bunch of stuff, but i've never had an issue with it
4:08:01
ghostyyy
iqubic, that only solves one half of the accidental caputre problem, the problem where your macro binds a name already in its context
4:08:15
beach
iqubic: Certain ideas in programming language design want to protect the programmer from himself/herself, so the language is trying to make it impossible to introduce certain problems.
4:08:23
ghostyyy
the other half is where the macro's context binds a name which has the same name as a global
4:18:26
drmeister
Hygienic macros are more important in a Lisp-1, with a single shared namespace for function names and variable names. Common Lisp is a Lisp-2 (or more?) and problems that hygienic macros solve in a Lisp-1 are more conveniently solved with GENSYM.
4:19:38
pfdietz
Also, there's less problem with overriding of functions by local variables in CL. Go ahead and use 'list' as a variable name, none of that schemish 'lst' stuff.
4:19:46
ghostyyy
drmeister, what about the problem i mentioned, where some code shadows a global variable, which is also used by a macro, and then that macro is invoked inside of that context?
4:20:45
Bike
yes. cl also prevents shadowing standard names, which mostly makes that not a problem, though it's not a very "clean" solution
4:21:33
beach
ghostyyy: Not sure whether you are talking about the expansion code or the expanded code.
4:22:05
Bike
(let ((x 4)) (macrolet ((m () 'x)) (let ((x 5)) (m)))) => 5 instead of 4, i'm guessing.
4:22:36
pfdietz
You don't want information to be passed down into macros using special variables. Use the macro environment.
4:23:33
ghostyyy
pfdietz, are you supposed to just pass every function that you plan on using inside of the macro to it via macro arguments?
4:24:03
beach
Bike: Sure, but if it only uses standard functions, the standard prevents shadowing, as you pointed out.
4:24:28
Bike
yeah. i'm just saying, pretty much any macroexpansion has free variables. it's just not usually an issue in practice.
4:24:41
pfdietz
ghostyyy: one thing to remember is that when you compile code, the macros are evaluated at compile time, not when the code they are in is run. So if that code binds a variable later, it doesn't affect the macro at all. The macro is already expanded.
4:26:19
beach
ghostyyy: A macro that expands to the use of a globally defined function that is not standard, is typically defined in the same package as that function.
4:27:19
beach
ghostyyy: So to have an accident, client code would have to write (flet ((package::secret-function (....))) (macro-call ...))
4:27:30
Bike
it's like, i get that common lisp macros are dangerous in theory, and that hygenic macros are safe, but it just has not happened for me
4:27:47
Bike
i have never run into this latter situation in several years of programming and had to be introduced to the possibility by an academic paper
4:28:13
ghostyyy
it honestly has never really occurred to me that someone might not think macro hygiene is an important thing to have, but i guess if its not a problem you encounter often then it makes sense
4:28:57
beach
ghostyyy: Perhaps it does for newbies who don't know about GENSYM, but not for programmers with a bit of experience.
4:29:04
pfdietz
Or, if it does happen, there are so many more common ways to shoot yourself in the foot that it doesn't matter.
4:29:07
ghostyyy
in retrospect i do find it kind of amusing that people have done serious academic research on how to let people get away with shadowing basic operations like cons
4:29:45
ghostyyy
still, i do feel like its a good thing, just that it gives you a nice guarantee that nothing bad will happen, no matter how hard you try
4:29:46
pfdietz
You can shadow CONS in CL. You work in a package where the symbol CONS means something else.
4:30:20
beach
ghostyyy: It is a matter of compromise. The more such guarantees that the language can provide, the harder it gets to use it.
4:31:54
Bike
i do like the conceptual simplicity of it. macro function's just a function you call on some code. obviously you can do all kinds of horrible things in that framework, but programming is all about that anyway
4:35:43
drmeister
ACTION prefers a powerful language that doesn't come with airbags, training wheels and safety rails. Wheee!
4:41:39
pfdietz
In a large project those get added back, layered on top of the language as social restrictions to get a large group of programmers to work well together. Things like "thou shalt not use :: on any symbols in your code".
6:20:41
drmeister
This is generated by the DO* macro and I'm trying to track down where they are coming from