libera/#lisp - IRC Chatlog
Search
5:41:16
a-m-g
Hey all. What I'm trying to do is check a switch, and if the switch is true, then bind these variables.
5:49:59
moon-child
if you are looking for something lexical, then, modulo mutation, something like (let ((x (if cond new-value x))) ...) would do the trick
5:51:10
moon-child
with mutation ... I don't think it would be possible to do better than duplicating the entire body (though of course that is a cinch with #n= et #n#)
8:13:12
holycow
what is the (, bit of the form? I have never seen that before an never seen that used anywhre. google returns nothing similar to that
8:20:31
holycow
i mean, that sounds right, i have never seen a flop inside a bracket and before any function / list item
8:25:43
wasamasa
> <program> and each <arg> are implicitly quasiquoted. <program> can be a string, symbol, number, or an unquote expression ,e that evaluates to a value of one of those types. Each <arg> follows the same rules as <program>, but can additionally be an unquote-splicing expression ,@e that evaluates to a list of multiple arguments where each element is a string, symbol, or number.
8:26:32
wasamasa
the idea is that normally, a macro invocation treats all of its arguments as if they're quoted, but an unquote would allow exceptions to this
8:26:34
holycow
oh. looks like i have a bunch of new learning to do. thank you kindly wasamasa. i really appreciate that!
8:28:12
wasamasa
note that this trick doesn't work universally in all the lisps, elisp for example doesn't support it
8:28:55
holycow
i have been avoiding macros, but i guess it is time to dig in. i did not expect the great links tho
12:15:21
capjamesg
Would anyone be up for quickly reviewing a simple program? It feels a bit verbose but I'm just glad I got it working :D
12:20:27
jackdaniel
http://turtleware.eu/static/paste/f8c730bd-cantdo.lisp improves slightly the style to be more "contemporary"
12:57:13
pjb
capjamesg: apart if for pedagogical reasons, why don't you just use a function instead of a macro? (explain-permissions "rwxr-xr-x") and (encode-permissions "rwxr-xr-x") -> #o755
14:05:05
jcowan
wasamasa: the quasiquoted-body trick is definitely portable Scheme, because Scheme insists on expanding `... to (quasiquote ...), and ,... to (unquote ...), etc.
14:06:06
jcowan
however, CL implementations are allowed to expand `(A ,B) directly to (LIST 'A B) or the equivalent, in which case there is no unquote to get a grip on.
14:06:42
jcowan
I was trying to figure out what sbcl does by feeding it '`(a ,b), but it replies `(a ,b)!
14:08:48
jcowan
Ah, turning off *print-pretty* does it, and I get (SB-INT:QUASIQUOTE (A #S(SB-IMPL::COMMA :EXPR B :KIND 0)))
14:14:57
aeth
',b probably could work in SBCL (but not necessarily every CL) but it would break portability so it doesn't
14:15:06
jcowan
The standard requires "read" to exist, and prescribes its behavior, but gives no standard way of modifying it. Some Schemes like Chicken support readtables, but others use non-table-driven approaches like recursive descent
14:20:40
jcowan
In the Chicken REPL the control commands are of the form ,foo; the reader expands this to (unquote foo), which the REPL looks for separately before calling eval.
14:21:40
jackdaniel
i.e clim listener does exactly that > ,foo looks up the command, while > foo looks up a variable
14:24:23
jackdaniel
to add some more reference points: ecl treats specially forms like :help when typed in its repl
16:51:55
jackdaniel
the language specifies semantics of operations. you may either compile the code or interpret it
16:52:19
jackdaniel
common lisp tends to have an excellent compilers, same goes for many scheme implementations
16:52:42
sham1
A language cannot be compiler or interpreted. Those are properties of an implementation of a given language
16:53:43
jackdaniel
sometimes a specification may make writing a compiler harder (or some optimizations impossible), so the language itself is relevant from this point of view
16:55:58
aeth
yeah, a language can be interpreted in the sense that it's nearly impossible (or impossible) to write a compiler due to its language features
16:56:21
aeth
Common Lisp is not such a language, and even in those cases, these days, a lot of "interpreted languages" use JIT compilation for speed
16:57:04
aeth
Not Scheme, either, though, so just about any Lisp that people talk about can be compiled.
16:57:20
White_Flame
terror_terry: is C interpreted or compiled? There are C interpreters around, too
16:57:49
aeth
CL prefers compilation, too, although CLISP compiles to a fairly simple interpreted bytecode in its "compilation" phase.
16:58:11
aeth
And some languages like JavaScript basically need to be JITed if they're compiled at all.
16:59:52
aeth
Common Lisp is fairly close to Python. OOP and stuff. And as long as you get over the fact that Python "lists" are actually just adjustable vectors, you get that fairly easy in Common Lisp (as vectors, not lists, which are linked lists in CL and in most languages)
17:00:24
aeth
Just between vectors, dynamic-style classes (constrast with Java or C++), and hash tables, Common Lisp should be fairly familiar except in syntax.
17:00:33
jackdaniel
I've read that python spec is actually pretty screwed up if we talk about writing compilers
17:01:23
sham1
And Scheme has the nice property of being the language of the SICP, so if you like relatively orthodox CS stuff, it'll do wonders
17:02:15
sham1
Not only have people written compilers in Python and for Python, there's also a compiler for Python in Python (technically RPython but shush(
17:03:43
sham1
Ah yes. So, the SICP as a book really nicely goes into how computer programs are structured (and I suppose how they're to be interpreted, although in this case more in the sense of what we as humans make of it)
17:14:43
Alfr
sham1, you mean, when they are actually working ... and not one of those days where they are demanding more pay and other perks?
17:16:50
Alfr
sham1, (also, unless your programs are human readable, how would you expect those ever getting run? :p)
17:19:11
jackdaniel
I think that people will be hestitant to give you advices, because that's a dangerous gift
17:19:31
jackdaniel
you are on lisp channel, so most probably /think/ that you should learn lisp, then (eventually) C ,)