Go Back   Science Forums
View Single Post
Old 11-14-2006   #5 (permalink)
CraigD's Avatar
CraigD
Creating


Location:
Silver Spring, MD, USA
 
CraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond reputeCraigD has a reputation beyond repute
 



Not Ranked  0 score     
Post Self-modifying MUMPS code

Quote:
Originally Posted by KickAssClown
Are there any computer languages that have primitives, or objects which contain not a value, or address, but a expression of the written language itself?
Some languages – especially interpreted (as opposed to compiled) one lend themselves better to what I thing you’re describing.

Though LISP is usually mentioned as a language that lends itself to containing expressions of itself, I’m fond of MUMPS (as anyone who’s noted the programs I’ve posted at hypography is likely aware ), which also lends itself to manipulating its own code.

Here’s a very simple example, cut from a MUMPS direct (interactive) mode terminal session (note the “USER>” is a typical direct mode prompt, not actual input or program output):
Code:
USER>r X
w 1 q:'5  s $p(X," ",3)="q:'"_($p(X,"'",2)-1) x X w 2
USER>x X
11111122222
USER>w X
w 1 q:'0  s $p(X," ",3)="q:'"_($p(X,"'",2)-1) x X w 2
USER>
This program counts down from 5 to 0. It’s not a particularly good or clever program, but remarkable in that the code contained in symbol X references no symbol but itself. Note that MUMPS keywords can be and usually are abbreviated (eg: r[ead] w[rite] q[uit] s[et] $p[iece] x[ecute]), leading many to comment that it looks like line noise.

It’s fairly easy to write much more complicated and meaningful self modifying MUMPS programs, such as in the puzzle game-playing program in my post ”Self modifying code in an interpreted language”.


----------------
Moderator: Computers and Technology; Medical Science; Science Projects and Homework; Philosophy of Science; Physics and Mathematics; Environmental Studies
Reply With Quote
 
» Advertisement
» Current Poll
Who's the sexiest man alive? Johnny Depp or Robert Pattinson?
Johnny Depp - 30.00%
3 Votes
Robert Pattinson - 0%
0 Votes
Someone else (please specify) - 40.00%
4 Votes
I'm too macho to think a guy is sexy - 30.00%
3 Votes
Total Votes: 10
You may not vote on this poll.


All times are GMT -8. The time now is 10:42 AM.

Hypography?

Hypography [n.]: A combination of "hyperlink" and "bibliography" - ie, a list of links to electronic documents. Comparable to discography and bibliography, but not cartography.

We have been online since May 2000, and aim to be the best place to find and share science-related content of all kinds.

Share the love!

Please add more science to your life. Use our RSS feeds on your blog, your portal, or your favorite feedreader!


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000-2009 Hypography
Part of the Hypography - Science for Everyone Network