Hacker News new | past | comments | ask | show | jobs | submit login

Show me how you would write self-modifying code in Lisp and I'll be happy to show you the analog. Replacing functions at runtime in Python is just as easy as replacing them at runtime in Lisp.



Ah, you might be setting yourself up for a fall there :) one of Lisp's key elements if the ability to be self modifying (a large amount of Lisp code you will see is self-modifying) to an extraordinary degree.

Python doesn't even begin to match it's abilities in this arena.

(intro: http://www.fact-index.com/s/se/self_modifying_code.html)


> Ah, you might be setting yourself up for a fall there :)

No, I'm not. Give your example.

> Python doesn't even begin to match it's abilities in this arena.

Sure it does. Give your example. To quote your (useless) link: "TODO an example and discussion of 'high-level' self-modifying code such as in LISP."


I am no Lisper - so someone else will have to do that. But it was shown to me on a couple of occasions and Lisp's abilities are stellar!

The problem is:

Replacing functions at runtime in Python is just as easy as replacing them at runtime in Lisp.

Is not the be all and end all of self-modifying code :)

EDIT: this is a pretty good intro to Lisp Macro's http://www.apl.jhu.edu/~hall/Lisp-Notes/Macros.html The code examples on there are fairly simple though (but it starts you in the right direction).

For example one thing Python is currently unable to do is modify a line in a function to do something completely arbitrary (well, theoretically you could code a specific line to be able to do that, but it wouldn't be trivial to make an entire function that could be trivially modified on the fly).

[we are now at the extent of my Lisp knowledge]


> I am no Lisper - so someone else will have to do that.

So you're making claims without firsthand knowledge? Awesome.

> Is not the be all and end all of self-modifying code :)

It's the vast majority of what people actually do in Lisp, and Python supports it just fine.

> EDIT: this is a pretty good intro to Lisp Macro's http://www.apl.jhu.edu/~hall/Lisp-Notes/Macros.html

Macros have nothing to do with self-modifying code. You clearly have no idea what you're talking about. Macros are compile-time transformations of code: they have no runtime effect whatsoever.

> The code examples on there are fairly simple though (but it starts you in the right direction).

Dude, I've got PG's ANSI Common Lisp on my bookshelf and I've read On Lisp multiple times. I understand macros. What I don't understand is this Lisp worship evinced by people who actually have no idea what they're talking about with respect to self-modifying code.

> For example one thing Python is currently unable to do is modify a line in a function to do something completely arbitrary (well, theoretically you could code a specific line to be able to do that, but it wouldn't be trivial to make an entire function that could be trivially modified on the fly).

Provide a Lisp example of "modifying a line in a function" that runs in SBCL and I'll show you the same code in Python. Seriously: you're the one making a claim here, you need to be backing it up.

P.S. I remain utterly unimpressed by the anonymous coward downmodding me, upmodding you, but clearly either unwilling or (more likely) unable to defend your claim. More semi-religious Lisp fanaticism <yawn>.


I apologise... the last reply I kinda retract, as you say - it was a bit silly.

I have to admit your posts came across as the old "My Language is As Good As Yours" argument, but it appears your a Lisper too? I have to also admit everything I have seen/heard says Lisp is the original self-modifying language and is damn good at it :) but in retrospect that wasn't the point you were making.

(I was hoping a Lisper would step in with some code... but apparently not...)

Handshake?


> I apologise... the last reply I kinda retract, as you say - it was a bit silly.

Thanks, I appreciate that.

> I have to admit your posts came across as the old "My Language is As Good As Yours" argument, but it appears your a Lisper too?

I'm well-versed in Lisp, but I don't typically choose it for personal or professional tasks for a number of reasons.

> I have to also admit everything I have seen/heard says Lisp is the original self-modifying language and is damn good at it :)

The original self-modifying code was assembly language (or, really, machine code). It's a useful trick when you're working with extremely constrained computers whose memories are measured in single digit kilobytes, but long ago was recognized as really difficult to use in writing quality software. Real self-modifying code, which means code that actually overwrites the instructions the processor will execute, makes it incredibly hard to reason about programs and debug the resulting software. Real self-modifying code was long ago relegated to the likes of Mel (<http://www.cs.utah.edu/~elb/folklore/mel.html>). As I understand it, most Lisp programmers simply mean that their system properly handles the replacement of most (all?) functions/methods/definitions at runtime, which is in large part true of Python as well.

I open to being corrected by a Lisp programmer using a modern Lisp (hence my request for SBCL) to show an example of real self-modifying code, but I really don't expect that any will, because I don't think anyone's seriously written such code since I was out of elementary school.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: