introduction to lisp

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

introduction to lisp

Jude DaShiell-2
This material might be useful for lisp and those writing buster.js code.
It might also be somewhat incorrect too.

http://cjohansen.no/


--


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Emanuel Berg-4
Jude DaShiell wrote:

> This material might be useful for lisp and
> those writing buster.js code. It might also be
> somewhat incorrect too.
>
> http://cjohansen.no/

A very ambitious article/project!

Here is the direct link:

    http://cjohansen.no/an-introduction-to-elisp/

Try byte-compiling the code! It will tell you
some things to improve, I think. But I don't
know since I get an error on line 24:

    (void-variable open-paren-pairs-count) in cond

When the byte-compiler is silent and the
program works there is a fair chance the
program is good.

Code style - consider replacing 'if X' with
`when' and 'if not X' with `unless' when there
isn't a second branch. Then there is no need
for explicit `progn's.

Also I would write

    (global-set-key (kbd "C-c C-d") 'buster-disable-test)

like this:

    (global-set-key "\C-c\C-d" #'buster-disable-test)

Keep it up!

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

John Ankarström
Emanuel Berg <[hidden email]> writes:

> Also I would write
>
>     (global-set-key (kbd "C-c C-d") 'buster-disable-test)
>
> like this:
>
>     (global-set-key "\C-c\C-d" #'buster-disable-test)

I'm 100% with you on everything else you said, but I personally
prefer the `kbd' notation. It's clearer and easier to understand,
because it's consistent with how Emacs itself displays key
bindings for the user (through `describe-key').

I do agree that #' is better than ' for functions :-)

- John

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Kaushal Modi
On Mon, Jun 19, 2017, 8:14 PM John Ankarström <[hidden email]> wrote:

> Emanuel Berg <[hidden email]> writes:
>
> > Also I would write
> >
> >     (global-set-key (kbd "C-c C-d") 'buster-disable-test)
> >
> > like this:
> >
> >     (global-set-key "\C-c\C-d" #'buster-disable-test)
>
> I'm 100% with you on everything else you said, but I personally
> prefer the `kbd' notation. It's clearer and easier to understand,
> because it's consistent with how Emacs itself displays key
> bindings for the user (through `describe-key').
>

+1. It's simply type what you see.

Example:
- How do I bind F1?
- Do C-h k F1.. Realize that emacs shows that as <f1>
- Simply wrap that with (kbd "...") and you have (kbd "<f1>")
- Put that in the global-set-key or define-key form.

I do agree that #' is better than ' for functions :-)
>

+1

> --

Kaushal Modi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Emanuel Berg-4
Kaushal Modi wrote:

> Example: - How do I bind F1? - Do C-h k F1..
> Realize that emacs shows that as <f1> -
> Simply wrap that with (kbd "...") and you
> have (kbd "<f1>") - Put that in the
> global-set-key or define-key form.

But that evaluates to [f1], so then why not

    (global-set-key [f1]
      (lambda () (interactive) (message "Formula 1")) )

?

Actually the only case I have against `kbd' is
that it is more bulky and longer to type...

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Tomas Zerolo
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Jun 20, 2017 at 06:59:14AM +0200, Emanuel Berg wrote:

> Kaushal Modi wrote:
>
> > Example: - How do I bind F1? - Do C-h k F1..
> > Realize that emacs shows that as <f1> -
> > Simply wrap that with (kbd "...") and you
> > have (kbd "<f1>") - Put that in the
> > global-set-key or define-key form.
>
> But that evaluates to [f1], so then why not
>
>     (global-set-key [f1]
>       (lambda () (interactive) (message "Formula 1")) )

But that evaluates to

  (global-set-key [f1] #[nil "ÀÁ!‡" [message "Formula 1"] 2 nil nil])

(I just asked byte-compile to tell me that). So why not write that
right away?

Of course, that was a bit tongue-in-cheek ;-P

What I mean: sometimes it makes sense to let people go the
extra ten meters to meet the computer (mainly because there's
an interesting spot to meet [1]), sometimes it makes sense
to let the computer do the walk, perhaps because the spot to
meet is pretty boring (personally, I find conventions to name
keys pretty boring, to be honest).

Which is which depends, of course, on Things :)

[1] as is the case with lambda calculus and The Lisps.
   Giving up on traditional infix arithmetic may feel
   awkward at first, but tends to bring some kind of
   Enlightenment upon (some of) us. Then we get high
   and all worked up and try to convince others and
   they look at us with those strange looks ;-D

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAllI4A8ACgkQBcgs9XrR2kYAYwCeJOvUx7eh/rWAwKtRy5RzhjFX
FLEAniZYfQlEGmVL6IPBfuN5QKx4EyvY
=RO1E
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Emanuel Berg-4
> What I mean: sometimes it makes sense to let
> people go the extra ten meters to meet the
> computer (mainly because there's an
> interesting spot to meet [1]), sometimes it
> makes sense to let the computer do the walk,
> perhaps because the spot to meet is pretty
> boring (personally, I find conventions to
> name keys pretty boring, to be honest).
>
> Which is which depends, of course, on Things
> :)
>
> [1] as is the case with lambda calculus and
> The Lisps. Giving up on traditional infix
> arithmetic may feel awkward at first, but
> tends to bring some kind of Enlightenment
> upon (some of) us. Then we get high and all
> worked up and try to convince others and they
> look at us with those strange looks ;-D

Hey, what's the secret? The only time *I'm*
this open-minded is when I take acid and then
I don't even care about computers anymore!

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Tomas Zerolo
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Jun 20, 2017 at 11:04:35AM +0200, Emanuel Berg wrote:

[...]

> > look at us with those strange looks ;-D
>
> Hey, what's the secret? The only time *I'm*
> this open-minded is when I take acid and then
> I don't even care about computers anymore!

Must be the onset of senility. I wish it were
some weed, then I could take more of it. So
I'm just forced to wait :-/

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAllI++EACgkQBcgs9XrR2kaglwCeIBfW43MlMLtXrwRefbbtBqdx
o08AmwaWIv9+X1ILX2l+k5QR8qhu+/hx
=9AOw
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Kaushal Modi
In reply to this post by Emanuel Berg-4
On Tue, Jun 20, 2017 at 1:00 AM Emanuel Berg <[hidden email]> wrote:

> But that evaluates to [f1], so then why not
>
>     (global-set-key [f1]
>       (lambda () (interactive) (message "Formula 1")) )
>
> ?
>

Not sure if that's a joke. Again, as I said, this approach is simply "what
is see is what you type"; with just kbd wrapped around. If you see <f1>,
the binding notation is (kbd "<f1>"), if you see C-c C-d, (kbd "C-c C-d"),
if you see <M-return>, (kbd "<M-return>"), and so on.


> Actually the only case I have against `kbd' is
> that it is more bulky and longer to type...
>

The value is not having to think if certain chars need to be escaped or
having to spend time doing one more eval to find the correct string.
--

Kaushal Modi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Emanuel Berg-4
Kaushal Modi wrote:

> Not sure if that's a joke. Again, as I said,
> this approach is simply "what is see is what
> you type"; with just kbd wrapped around.

...except when the extra length of the `kbd'
from makes the line too long pushing the code
fragment outside of the screen, on the contrary
making it invisible!

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: introduction to lisp

Narendra Joshi
In reply to this post by Tomas Zerolo
<[hidden email]> writes:

> On Tue, Jun 20, 2017 at 06:59:14AM +0200, Emanuel Berg wrote:
>> Kaushal Modi wrote:
>>
>> > Example: - How do I bind F1? - Do C-h k F1..
>> > Realize that emacs shows that as <f1> -
>> > Simply wrap that with (kbd "...") and you
>> > have (kbd "<f1>") - Put that in the
>> > global-set-key or define-key form.
>>
>> But that evaluates to [f1], so then why not
>>
>>     (global-set-key [f1]
>>       (lambda () (interactive) (message "Formula 1")) )
>
> But that evaluates to
>
>   (global-set-key [f1] #[nil "ÀÁ!‡" [message "Formula 1"] 2 nil nil])
>
> (I just asked byte-compile to tell me that). So why not write that
> right away?
>
> Of course, that was a bit tongue-in-cheek ;-P
>
> What I mean: sometimes it makes sense to let people go the
> extra ten meters to meet the computer (mainly because there's
> an interesting spot to meet [1]), sometimes it makes sense
What do you use for footnotes? [An unrelated question]

> to let the computer do the walk, perhaps because the spot to
> meet is pretty boring (personally, I find conventions to name
> keys pretty boring, to be honest).
>
> Which is which depends, of course, on Things :)
>
> [1] as is the case with lambda calculus and The Lisps.
>    Giving up on traditional infix arithmetic may feel
>    awkward at first, but tends to bring some kind of
>    Enlightenment upon (some of) us. Then we get high
>    and all worked up and try to convince others and
>    they look at us with those strange looks ;-D
>
> Cheers
> -- tomás
>

--
Narendra Joshi

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Footnotes [was: introduction to lisp]

Tomas Zerolo
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jun 25, 2017 at 01:04:35PM +0530, Narendra Joshi wrote:
> <[hidden email]> writes:

[unrelated stuff]

> What do you use for footnotes? [An unrelated question]

I'm sorry to disappoint you -- my footnotes are (so far) pedestrian.
Boring, I know :)

In bigger texts they tend to be org-mode, though.

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAllPi5QACgkQBcgs9XrR2kbnKgCeO2a0RdWBcCdgFh2GRdv8LfkC
bPwAn0wfIuoEWNsV6XRlQ0j3nxLQY/5/
=Dhm2
-----END PGP SIGNATURE-----

Loading...