martes, 24 de julio de 2012

Maybe google doesn't know so much about me





Thank you.

sábado, 21 de julio de 2012

When mapcan backfires

While writing some elisp for clasker (still alpha), The destructive function mapcan backfired in a really strange way.

Calling mapcan on a list of really simple functions that just returned lists, worked ok, but just the first time.

The issue is a combination of different things, mainly Iterating through functions that return quoted lists.  When nconc does its thing, it uses the lists in place, so we're indeed modifying the defuns.

Here's the small code that exemplifies the issue, and a possible way to avoid it.

ELISP> (defun t1 () '("hola"))
ELISP> (defun t2 () (list "adeu"))
ELISP> (t1) 

ELISP> (t2)

ELISP> (mapcan 'funcall '(t1 t2))
("hola" "adeu")

ELISP> (t1)
("hola" "adeu") ; => Oops, t1 has been modified

ELISP> (mapcan 'funcall '(t2 t1))
("adeu" "hola" "adeu")

ELISP> (t2)

ELISP> (defun t1 () '("hola")) ; Redefine t1 and t2 for sanity assurance
ELISP> (mapcan 'funcall '(t2 t1))
("adeu" "hola")

ELISP> (t2) 
("adeu") ; => t2 is fine

Generating the lists with the (list ...) function solves the issue, because a new object is created every time, so we're not returning the literal object from the source.

Also,  (reduce 'append (mapcar ...)) will do "the right thing" (tm)

jueves, 5 de julio de 2012

Learn javascript as a little schemer

I recently found a blogpost talking about javascript prototypes in a very funny and uncommon way. It was funny to read, easy to follow, and high on insights. Out of the sudden, something clicked in my brain, and I thought:

 - Aha!, I've seen this way of explaining things in some other place! It's like the Little Schemer (and all the schemers collection (which I haven't read (yet)))!

 Then, I checked other posts on the same blog, and most articles follow the same socratic experience of explaining things.

 Really, it's funny, and it builds up on you.

 Well, and here's the url of the blog. Kudos to AngusCroll (author), you have a new blog follower.

EDIT: I just found another instersting post for js wannabies like me. Simpler, but interesting read

miércoles, 4 de julio de 2012

"Chrome does UDP sockets" joke

Opening a new section, here's the first post in the new section irclog, where I'll just copypaste remarkable pearls that appear in one or other channel I'm usually logged. Be prepared for geek jokes. I can't promise to be involved in all :) And here's the first. with my 3scale coworkers
<a> "Chrome supports TCP & UDP Sockets"
<a> you can do udp jokes in chrome now
<rgrau> I didn't get it
<a> I don't care
<rgrau> great!