[#343034] RUBY vs COMMON LISP — fft1976 <fft1976@...>

On Aug 1, 8:55=A0pm, p...@informatimago.com (Pascal J. Bourguignon)

16 messages 2009/08/02

[#343054] Inconsistency in Array#[] — Wojciech Piekutowski <w.piekutowski@...>

Disclaimer: I know what docs say, but I'd prefer a different

14 messages 2009/08/02

[#343135] Kind of ParsTree for 1.9.1 — Macario Ortega <macarui@...>

22 messages 2009/08/04

[#343186] Bizarre Range behavior — Scott Briggs <scott.br@...>

Can someone please explain this behavior in ruby (1.8.6p111):

42 messages 2009/08/04
[#343187] Re: Bizarre Range behavior — Yossef Mendelssohn <ymendel@...> 2009/08/04

On Aug 4, 1:47=A0pm, Scott Briggs <scott...@gmail.com> wrote:

[#343193] Re: Bizarre Range behavior — Rob Biedenharn <Rob@...> 2009/08/04

On Aug 4, 2009, at 3:04 PM, Yossef Mendelssohn wrote:

[#343196] Re: Bizarre Range behavior — "Matthew K. Williams" <matt@...> 2009/08/04

On Wed, 5 Aug 2009, Rob Biedenharn wrote:

[#343199] Re: Bizarre Range behavior — Rob Biedenharn <Rob@...> 2009/08/04

On Aug 4, 2009, at 3:45 PM, Matthew K. Williams wrote:

[#343234] Re: Bizarre Range behavior — Yukihiro Matsumoto <matz@...> 2009/08/05

Hi,

[#343251] Re: Bizarre Range behavior — Brian Candler <b.candler@...> 2009/08/05

Yukihiro Matsumoto wrote:

[#343261] Re: Bizarre Range behavior — Yukihiro Matsumoto <matz@...> 2009/08/05

Hi,

[#343266] Re: Bizarre Range behavior — "David A. Black" <dblack@...> 2009/08/05

Hi --

[#343272] Re: Bizarre Range behavior — Yukihiro Matsumoto <matz@...> 2009/08/05

Hi,

[#343273] Re: Bizarre Range behavior — Rick DeNatale <rick.denatale@...> 2009/08/05

On Wed, Aug 5, 2009 at 12:21 PM, Yukihiro Matsumoto<matz@ruby-lang.org> wro=

[#343235] remove commas from string — Jason Lillywhite <jason.lillywhite@...>

I have following string:

14 messages 2009/08/05

[#343288] including gems with standalone app — Eric Peterson <ericdp@...>

Morning,

10 messages 2009/08/05

[#343320] 1.9 String and M17N documentation — Brian Candler <b.candler@...>

I have put together a document which tries to outline the M17N

20 messages 2009/08/06
[#343351] Re: [ANN] 1.9 String and M17N documentation — James Gray <james@...> 2009/08/06

On Aug 6, 2009, at 6:47 AM, Brian Candler wrote:

[#343378] Re: [ANN] 1.9 String and M17N documentation — Eric Hodel <drbrain@...7.net> 2009/08/07

On Aug 6, 2009, at 08:57, James Gray wrote:

[#343423] How do I add ? — chutsu <chutsu@...>

I've got a file that is in two columns, how do I add the second column

14 messages 2009/08/07

[#343566] Reading contents of a file and storing — Shekar Ls <idealone5@...>

Guys,

14 messages 2009/08/10

[#343592] Destroying related objects doubt ... basic oop question — Soh Dubom <sohdubom@...>

::Destroying related objects doubt

16 messages 2009/08/10
[#343726] Re: Destroying related objects doubt ... basic oop question — Mike Stephens <rubfor@...> 2009/08/12

Yet another reason for steering well clear of object-relational mappers.

[#343751] Re: Destroying related objects doubt ... basic oop question — Fabian Streitel <karottenreibe@...> 2009/08/12

> Yet another reason for steering well clear of object-relational mappers.

[#343649] Good editor for Windows Ruby — Peter Bailey <pbailey@...>

Hello,

21 messages 2009/08/11

[#343658] Readline not working with Ruby — Stewart <stewart.matheson@...>

24 messages 2009/08/11

[#343756] Class#descendants? — Jason Lillywhite <jason.lillywhite@...>

Ruby can do Class#ancestors but not Class#descendants.

18 messages 2009/08/12
[#343757] Re: Class#descendants? — Joel VanderWerf <vjoel@...> 2009/08/12

Jason Lillywhite wrote:

[#343771] skip_before_filter (Do I need a lesson in modules/mixins?) — Cris Shupp <cshupp1@...>

Gurus,

13 messages 2009/08/12

[#343831] newbie question making a folder with ruby — Simon Staton <simon@...>

ok well the program I am in the middle of programming I need it to

20 messages 2009/08/13
[#343851] Re: newbie question making a folder with ruby — Lui Core <usurffx@...> 2009/08/13

Simon Staton wrote:

[#343898] Re: newbie question making a folder with ruby — Simon Staton <simon@...> 2009/08/14

Lui Core wrote:

[#343902] Re: newbie question making a folder with ruby — Simon Staton <simon@...> 2009/08/14

To give more of an idea this is the code that I have on the .rb file. it

[#343920] Class method aliased in superclass bypasses subclass overrides — Marcos <markjreed@...>

This seems like it should work:

11 messages 2009/08/14

[#344009] start_with? Does someone need a grammar lesson? — 7stud -- <bbxx789_05ss@...>

String#start_with?-------------------------------

15 messages 2009/08/17

[#344088] fromdos dos2unix in ruby — Krzysztof Cierpisz <ciapecki@...>

how can I achieve in ruby the result of running:

18 messages 2009/08/18
[#344103] Re: fromdos dos2unix in ruby — krzysztof cierpisz <ciapecki@...> 2009/08/18

>

[#344109] Re: fromdos dos2unix in ruby — Robert Klemme <shortcutter@...> 2009/08/18

2009/8/18 krzysztof cierpisz <ciapecki@gmail.com>:

[#344125] exercise in DRY — Peter Ehrlich <crazedcougar@...>

I have some simple code for a thumbs up/thumbs down functionality.

13 messages 2009/08/18

[#344180] #has_arguments? — Intransition <transfire@...>

Messing with optional argument check for the umpteenth time, eg.

23 messages 2009/08/19

[#344218] Confirm my Performance Test Against Java? — Ben Christensen <benjchristensen@...>

I'm evaluating Ruby for use in a variety of systems that are planned by

40 messages 2009/08/19
[#344222] Re: Confirm my Performance Test Against Java? — brabuhr@... 2009/08/19

On Wed, Aug 19, 2009 at 9:31 AM, Ben Christensen

[#344342] extending ruby - handling errors — Jason Lillywhite <jason.lillywhite@...>

I want to raise an ArgumentError, "Function only takes numeric objects."

11 messages 2009/08/20

[#344345] How do I estimate how long it will take a calculation to complete? — Paul <tester.paul@...>

Hi there, I wrote a short ruby script to calculate the prime factors

10 messages 2009/08/20

[#344366] Why, oh why, _why? — Karl von Laudermann <doodpants@...>

_why the lucky stiff appears to have disappeared from the internets!

79 messages 2009/08/20
[#344400] Re: Why, oh why, _why? — Ralf Mueller <ralf.mueller@...> 2009/08/21

Karl von Laudermann wrote:

[#344421] Re: Why, oh why, _why? — Gregory Brown <gregory.t.brown@...> 2009/08/21

On Fri, Aug 21, 2009 at 4:24 AM, Ralf Mueller<ralf.mueller@zmaw.de> wrote:

[#344432] Re: Why, oh why, _why? — Rick DeNatale <rick.denatale@...> 2009/08/21

On Fri, Aug 21, 2009 at 7:17 AM, Gregory Brown<gregory.t.brown@gmail.com> w=

[#344434] Re: Why, oh why, _why? — Gregory Brown <gregory.t.brown@...> 2009/08/21

On Fri, Aug 21, 2009 at 9:49 AM, Rick DeNatale<rick.denatale@gmail.com> wro=

[#344441] Re: Why, oh why, _why? — Jason Roelofs <jameskilton@...> 2009/08/21

On Fri, Aug 21, 2009 at 9:54 AM, Gregory Brown <gregory.t.brown@gmail.com>wrote:

[#344448] Re: Why, oh why, _why? — Xavier Noria <fxn@...> 2009/08/21

On Fri, Aug 21, 2009 at 4:07 PM, Jason Roelofs<jameskilton@gmail.com> wrote:

[#344453] Re: Why, oh why, _why? — Jason Roelofs <jameskilton@...> 2009/08/21

On Fri, Aug 21, 2009 at 10:23 AM, Xavier Noria <fxn@hashref.com> wrote:

[#344525] Re: Why, oh why, _why? — Todd Benson <caduceass@...> 2009/08/22

On Thu, Aug 20, 2009 at 3:10 PM, Karl von

[#344526] Re: Why, oh why, _why? — Todd Benson <caduceass@...> 2009/08/22

On Sat, Aug 22, 2009 at 7:43 AM, Todd Benson<caduceass@gmail.com> wrote:

[#344404] How to convert string "/regexp/i" to /regexp/i - ? — Joao Silva <rubyforum@...>

When i try to use:

20 messages 2009/08/21

[#344462] Github and _why — John W Higgins <wishdev@...>

I'm about to get very nasty responses but this absolutely is a very bad

19 messages 2009/08/21
[#344467] Re: Github and _why — Tony Arcieri <tony@...> 2009/08/21

On Fri, Aug 21, 2009 at 10:38 AM, John W Higgins <wishdev@gmail.com> wrote:

[#344545] 1.8.7 String#lines keeps new-line chars (say it ain't so in 1.9) — Intransition <transfire@...>

Ruby 1.8.7 p72

19 messages 2009/08/22

[#344554] Ruby Editor — sasan <sasan.bahrieh@...>

I need a good software for ruby programming. please post message for

21 messages 2009/08/22

[#344573] ruby-debug does not hit breakpoints at class-methods — Sys Ppp <systemppp@...>

ruby-1.8.6-p369

19 messages 2009/08/22
[#344593] Re: ruby-debug does not hit breakpoints at class-methods — 7stud -- <bbxx789_05ss@...> 2009/08/23

...and more

[#344597] Re: ruby-debug does not hit breakpoints at class-methods — Sys Ppp <systemppp@...> 2009/08/23

> $ rdebug r2test.rb

[#344652] Re: ruby-debug does not hit breakpoints at class-methods — 7stud -- <bbxx789_05ss@...> 2009/08/24

Sys Ppp wrote:

[#344653] Re: ruby-debug does not hit breakpoints at class-methods — 7stud -- <bbxx789_05ss@...> 2009/08/24

...or I guess this would be a better example:

[#344656] Re: ruby-debug does not hit breakpoints at class-methods — Sys Ppp <systemppp@...> 2009/08/24

To 7stud. These are all normal, except class-method, as i wrote.

[#344691] Re: ruby-debug does not hit breakpoints at class-methods — Rick DeNatale <rick.denatale@...> 2009/08/24

On Sun, Aug 23, 2009 at 11:50 PM, Sys Ppp<systemppp@gmail.com> wrote:

[#344705] Re: ruby-debug does not hit breakpoints at class-methods — Sys Ppp <systemppp@...> 2009/08/24

Rick Denatale wrote:

[#344580] Development - works, production not - why? — Joao Silva <rubyforum@...>

My development envrioment:

11 messages 2009/08/23

[#344680] Comparison Ruby, Python, Php, Groovy ecc. — Marco Mastrodonato <m.mastrodonato@...>

Comparison script languages for the fractal geometry, these are the

25 messages 2009/08/24
[#344684] Re: Comparison Ruby, Python, Php, Groovy ecc. — Urabe Shyouhei <shyouhei@...> 2009/08/24

Are those executables compiled with identical compilers + compile flags?

[#344717] _why's "suicide" note? — Graham Agnew <graham.agnew@...>

Just found this as _why's last tweet on the Google cached copy of _why's

12 messages 2009/08/24

[#344762] Calling method from another class — Kostas Lps <louposk@...>

Hi guys,

15 messages 2009/08/24

[#344872] ||= with 1.8 and 1.9 ? — Aldric Giacomoni <aldric@...>

A friend of mine on Twitter recently posted this tidbit of code:

30 messages 2009/08/26
[#344879] Re: ||= with 1.8 and 1.9 ? — Brian Candler <b.candler@...> 2009/08/26

Aldric Giacomoni wrote:

[#344899] Re: ||= with 1.8 and 1.9 ? — Rick DeNatale <rick.denatale@...> 2009/08/26

On Wed, Aug 26, 2009 at 11:08 AM, Brian Candler<b.candler@pobox.com> wrote:

[#344921] Re: ||= with 1.8 and 1.9 ? — Brian Candler <b.candler@...> 2009/08/26

Rick Denatale wrote:

[#344923] Re: ||= with 1.8 and 1.9 ? — Joel VanderWerf <vjoel@...> 2009/08/26

Brian Candler wrote:

[#344881] # sign does not work as expected form irb — Salvador Sanjuan <salvador.sanjuan@...>

I have just started Ruby. I have tried to do some exercises usin irb but

15 messages 2009/08/26
[#344887] Re: # sign does not work as expected form irb — Aldric Giacomoni <aldric@...> 2009/08/26

Salvador Sanjuan wrote:

[#344988] Re: # sign does not work as expected form irb — Salvador Sanjuan <salvador.sanjuan@...> 2009/08/27

Aldric Giacomoni wrote:

[#344938] Rack must not dictate how to create a middleware — Sys Ppp <systemppp@...>

In current realization of Rack::Builder the method :use dictates that

15 messages 2009/08/26
[#344940] Re: Rack must not dictate how to create a middleware — Brian Candler <b.candler@...> 2009/08/26

Sys Ppp wrote:

[#345037] Possible to use Ruby for Dynamic HTML sites without Rails? — Frank Peterson <fictionalperson@...>

How easy is this to do? I've been going though a Ruby book again (was

13 messages 2009/08/27

[#345070] I need a string#all_indices method--is there such a thing? — timr <timrandg@...>

In ruby you can use string#index as follows:

22 messages 2009/08/28

[#345079] #map, #select semantics — James Coglan <jcoglan@...>

I imagine this has come up before, though I can't find anything about it. I

16 messages 2009/08/28

[#345097] How to call this method — Robert Dober <robert.dober@...>

Hi list

15 messages 2009/08/28
[#345100] Re: How to call this method — Robert Klemme <shortcutter@...> 2009/08/28

2009/8/28 Robert Dober <robert.dober@gmail.com>:

[#345222] Sorting an array by multiple elements? — Paul <tester.paul@...>

Hi there, I have an array of arrays that I want to sort by multiple

14 messages 2009/08/30

[#345267] What is the ruby conventions to name private method? — pierr <pierr.chen@...>

16 messages 2009/08/31
[#345274] Re: What is the ruby conventions to name private method? — Ryan Davis <ryand-ruby@...> 2009/08/31

[#345322] help on phps $$ equivalent in ruby — Arthur Rats <simon.jacobs.ams@...>

i just cant find this anywhere, googling for a while and read up tons on

11 messages 2009/08/31

Re: RUBY vs COMMON LISP

From: fft1976 <fft1976@...>
Date: 2009-08-03 04:05:05 UTC
List: ruby-talk #343066
On Aug 1, 10:26=A0pm, fft1976 <fft1...@gmail.com> wrote:
> On Aug 1, 8:55=A0pm, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>
> > w_a_x_man <w_a_x_...@yahoo.com> writes:
> > > On Aug 1, 9:32 am, Bata <batabo...@yahoo.ca> wrote:
> > >> Use (cl-ppcre:split " " string-name) to get a list of the different
> > >> words in the string.
>
> > >> Check out the cl-ppcre package's functionality, its quite amazing.
>
> > > Ruby:
>
> > > string_name.split
>
> > Don't you realize how ugly Ruby syntax is?
>
> > Here is in 150 lines of lisp, a simplified lisp reader that is able to
> > read all the lisp syntax needed to write it.
>
> > Try to parse Ruby syntax in Ruby and see how useless a language it is.
>
> I much prefer CL to Ruby, but this argument is useless. How many lines
> of code do you need to read Brainfuck in Brainfuck?
>
> (If you wanted to show the inferiority of Ruby to Common Lisp, the
> shootout makes a much more compelling argument)
>
> > -----(simple-reader.lisp)----------------------------------------------=
--------
> > ;;;; -*- mode:lisp;coding:utf-8 -*-
> > ;;;;*******************************************************************=
*******
> > ;;;;FILE: =A0 =A0 =A0 =A0 =A0 =A0 =A0 simple-reader.lisp
> > ;;;;LANGUAGE: =A0 =A0 =A0 =A0 =A0 Common-Lisp
> > ;;;;SYSTEM: =A0 =A0 =A0 =A0 =A0 =A0 Common-Lisp
> > ;;;;USER-INTERFACE: =A0 =A0 NONE
> > ;;;;DESCRIPTION
> > ;;;; =A0 =A0
> > ;;;; =A0 =A0Simple Lisp Reader.
> > ;;;; =A0 =A0This reader implements a subset of the Common Lisp reader,
> > ;;;; =A0 =A0but it should be extensible enough to be able to read most
> > ;;;; =A0 =A0of Common Lisp syntax.
> > ;;;; =A0 =A0Not supported: the preserving whitespace flag, the recursiv=
e flag
> > ;;;; =A0 =A0(therefore no references), character traits (escapes).
> > ;;;; =A0 =A0Otherwise, reader macros and dispatching =A0macros can be w=
ritten
> > ;;;; =A0 =A0to read most of CL syntax.
> > ;;;; =A0 =A0Only integers, keywords and symbol tokens are parsed (a mor=
e
> > ;;;; =A0 =A0sophisticated parse-token function can be configured).
> > ;;;; =A0 =A0
> > ;;;;AUTHORS
> > ;;;; =A0 =A0<PJB> Pascal J. Bourguignon <p...@informatimago.com>
> > ;;;;MODIFICATIONS
> > ;;;; =A0 =A02009-08-02 <PJB> Created.
> > ;;;;BUGS
> > ;;;;LEGAL
> > ;;;; =A0 =A0GPL
> > ;;;; =A0 =A0
> > ;;;; =A0 =A0Copyright Pascal J. Bourguignon 2009 - 2009
> > ;;;; =A0 =A0
> > ;;;; =A0 =A0This program is free software; you can redistribute it and/=
or
> > ;;;; =A0 =A0modify it under the terms of the GNU General Public License
> > ;;;; =A0 =A0as published by the Free Software Foundation; either versio=
n
> > ;;;; =A0 =A02 of the License, or (at your option) any later version.
> > ;;;; =A0 =A0
> > ;;;; =A0 =A0This program is distributed in the hope that it will be
> > ;;;; =A0 =A0useful, but WITHOUT ANY WARRANTY; without even the implied
> > ;;;; =A0 =A0warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > ;;;; =A0 =A0PURPOSE. =A0See the GNU General Public License for more det=
ails.
> > ;;;; =A0 =A0
> > ;;;; =A0 =A0You should have received a copy of the GNU General Public
> > ;;;; =A0 =A0License along with this program; if not, write to the Free
> > ;;;; =A0 =A0Software Foundation, Inc., 59 Temple Place, Suite 330,
> > ;;;; =A0 =A0Boston, MA 02111-1307 USA
> > ;;;;*******************************************************************=
*******
>
> > (defstruct character-description
> > =A0 non-terminating-p
> > =A0 reader-macro
> > =A0 dispatching-macro-characters)
>
> > (defstruct (simple-readtable (:constructor %make-simple-readtable))
> > =A0 (default-character-description (make-character-description))
> > =A0 (macro-characters (make-hash-table))
> > =A0 (parse-token (function identity))
> > =A0 (whitespaces =A0#(#\space #\tab #\newline #\linefeed #\return #\pag=
e #\vt)))
>
> > (defun simple-get-macro-character (character &optional (readtable *simp=
le-readtable*))
> > =A0 (let ((description (or (gethash character (simple-readtable-macro-c=
haracters readtable))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(simple-readtable-de=
fault-character-description readtable))))
> > =A0 =A0 (values (character-description-reader-macro description)
> > =A0 =A0 =A0 =A0 =A0 =A0 (character-description-non-terminating-p descri=
ption))))
>
> > (defun simple-set-macro-character (character function &optional non-ter=
minating-p
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
(readtable *simple-readtable*))
> > =A0 (setf (gethash character (simple-readtable-macro-characters readtab=
le))
> > =A0 =A0 =A0 =A0 (make-character-description :non-terminating-p non-term=
inating-p
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 :reader-macro function))
> > =A0 't)
>
> > (defun simple-get-dispatch-macro-character (character subchar
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 &optional (readtable *simple-readtable*))
> > =A0 (setf subchar (char-upcase subchar))
> > =A0 (let ((description (gethash character (simple-readtable-macro-chara=
cters readtable))))
> > =A0 =A0 (unless (and description
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(character-description-dispatching-m=
acro-characters description))
> > =A0 =A0 =A0 (error "#\\~C is not a dispatching macro character" charact=
er))
> > =A0 =A0 (gethash subchar (character-description-dispatching-macro-chara=
cters description))))
>
> > (defun simple-set-dispatch-macro-character (character subchar function
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 &optional (readtable *simple-readtable*))
> > =A0 (setf subchar (char-upcase subchar))
> > =A0 (let ((description (gethash character (simple-readtable-macro-chara=
cters readtable))))
> > =A0 =A0 (when (or (null description)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 (null (character-description-dispatching-ma=
cro-characters description)))
> > =A0 =A0 =A0 (setf (gethash character (simple-readtable-macro-characters=
 readtable))
> > =A0 =A0 =A0 =A0 =A0 =A0 (make-character-description :non-terminating-p =
t
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 :reader-macro (function simple-reader-dispatching-macro)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 :dispatching-macro-characters (make-hash-table)))))
> > =A0 (let ((description (gethash character (simple-readtable-macro-chara=
cters readtable))))
> > =A0 =A0 (setf (gethash subchar =A0(character-description-dispatching-ma=
cro-characters description))
> > =A0 =A0 =A0 =A0 =A0 function))
> > =A0 't)
>
> > (defun simple-reader-dispatching-macro (character stream)
> > =A0 (let* ((subchar =A0(read-char stream))
> > =A0 =A0 =A0 =A0 =A0(macro =A0 =A0(simple-get-dispatch-macro-character c=
haracter subchar)))
> > =A0 =A0 (assert macro () "~C~C is not a dispatching macro" character su=
bchar)
> > =A0 =A0 (funcall macro character subchar stream)))
>
> > (defun simple-read-vector-dmacro (char subchar stream)
> > =A0 (declare (ignore char))
> > =A0 (let ((contents (simple-read-list-macro subchar stream)))
> > =A0 =A0 (coerce contents 'vector)))
>
> > (defvar *character-names* (list (cons "SPACE" =A0 =A0(code-char 32))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
NEWLINE" =A0(code-char 10))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
RETURN" =A0 (code-char 13))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
PAGE" =A0 =A0 (code-char 12))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
VT" =A0 =A0 =A0 (code-char 11))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
LINEFEED" (code-char 10))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (cons "=
TAB" =A0 =A0 =A0(code-char 9)))
> > =A0 "An a-list mapping character names to characters.")
>
> > (defun simple-read-character-dmacro (char subchar stream)
> > =A0 (declare (ignore char subchar))
> > =A0 (let ((object (read-char stream)))
> > =A0 =A0 (if (alpha-char-p (peek-char nil stream nil #\space))
> > =A0 =A0 =A0 =A0 (loop
> > =A0 =A0 =A0 =A0 =A0 =A0:with buffer =3D (make-array 8 :element-type 'ch=
aracter :adjustable t :fill-pointer 1
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 :initial-element object)
> > =A0 =A0 =A0 =A0 =A0 =A0:do (vector-push-extend (read-char stream) buffe=
r)
> > =A0 =A0 =A0 =A0 =A0 =A0:while (alpha-char-p (peek-char nil stream nil #=
\space))
> > =A0 =A0 =A0 =A0 =A0 =A0:finally (return (or (cdr (assoc (string-upcase =
buffer) *character-names*
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 :test (function string=3D)))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (aref b=
uffer 0))))
> > =A0 =A0 =A0 =A0 object)))
>
> > (defun simple-parse-token (buffer)
> > =A0 ;; We only deal with integers, keywords and symbols.
> > =A0 (or (ignore-errors (parse-integer buffer :junk-allowed nil))
> > =A0 =A0 =A0 (if (char=3D #\: (aref buffer 0))
> > =A0 =A0 =A0 =A0 =A0 (intern (string-upcase (subseq buffer (position #\:=
 buffer :test (function char/=3D))))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "KEYWORD")
> > =A0 =A0 =A0 =A0 =A0 ;; We don't deal with other packages in this simple=
 parse-token.
> > =A0 =A0 =A0 =A0 =A0 (intern (string-upcase buffer)))))
>
> > (defun simple-read-quote-macro (character stream)
> > =A0 (declare (ignore character))
> > =A0 (list 'quote (simple-read stream)))
>
> > (defun simple-read-list-macro (character stream)
> > =A0 (declare (ignore character))
> > =A0 (loop
> > =A0 =A0 =A0:until (char=3D #\) (peek-char t stream))
> > =A0 =A0 =A0:collect (simple-read stream)
> > =A0 =A0 =A0:finally (read-char stream)))
>
> > (defun simple-read-string-macro (character stream)
> > =A0 (handler-case
> > =A0 =A0 =A0 (loop
> > =A0 =A0 =A0 =A0 =A0:with buffer =3D (make-array 8 :element-type 'charac=
ter :adjustable t :fill-pointer 0)
> > =A0 =A0 =A0 =A0 =A0:for ch =3D (read-char stream)
> > =A0 =A0 =A0 =A0 =A0:until (char=3D character ch)
> > =A0 =A0 =A0 =A0 =A0:do (vector-push-extend (if (char=3D #\\ ch)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0(read-char stream)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0ch)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0buff=
er)
> > =A0 =A0 =A0 =A0 =A0:finally (return (copy-seq buffer)))))
>
> > (defun simple-read-comment-macro (character stream)
> > =A0 (declare (ignore character))
> > =A0 (read-line stream)
> > =A0 (values))
>
> > (defun make-simple-readtable ()
> > =A0 (let ((readtable
> > =A0 =A0 =A0 =A0 =A0(%make-simple-readtable
> > =A0 =A0 =A0 =A0 =A0 :default-character-description (make-character-desc=
ription :non-terminating-p t)
> > =A0 =A0 =A0 =A0 =A0 :parse-token (function simple-parse-token))))
> > =A0 =A0 (simple-set-macro-character #\( (function simple-read-list-macr=
o) =A0 =A0 nil readtable)
> > =A0 =A0 (simple-set-macro-character #\) nil =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nil readtable)
> > =A0 =A0 (simple-set-macro-character #\' (function simple-read-quote-mac=
ro) =A0 =A0nil readtable)
> > =A0 =A0 (simple-set-macro-character #\" (function simple-read-string-ma=
cro) =A0 nil readtable)
> > =A0 =A0 (simple-set-macro-character #\; (function simple-read-comment-m=
acro) =A0nil readtable)
> > =A0 =A0 (simple-set-dispatch-macro-character #\# #\\ (function simple-r=
ead-character-dmacro) readtable)
> > =A0 =A0 (simple-set-dispatch-macro-character #\# #\( (function simple-r=
ead-vector-dmacro) =A0 =A0readtable)
> > =A0 =A0 readtable))
>
> > (defparameter *simple-readtable* (make-simple-readtable))
>
> > (defun simple-read (&optional (stream *standard-input*) (eof-error-p t)=
 eof-value)
> > =A0 (peek-char t stream nil)
> > =A0 (let ((char (read-char stream nil nil)))
> > =A0 =A0 (cond
> > =A0 =A0 =A0 (char
> > =A0 =A0 =A0 =A0(multiple-value-bind (macro non-terminating-p) (simple-g=
et-macro-character char)
> > =A0 =A0 =A0 =A0 =A0(if macro
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0(let ((object (multiple-value-list (funcall =
macro char stream))))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(if object (first object) (simple-read s=
tream eof-error-p eof-value))) =A0 =A0 =A0 =A0
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0(loop
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :with buffer =3D (make-array 8 :element=
-type 'character :adjustable t :fill-pointer 0)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :for ch =3D (peek-char nil stream nil #=
\space)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :initially (vector-push-extend char buf=
fer)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :until (or (position ch (simple-readtab=
le-whitespaces *simple-readtable*))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(not (nth-value =
1 (simple-get-macro-character ch))))
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :do (vector-push-extend (read-char stre=
am eof-error-p eof-value) buffer)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :finally (return (funcall (simple-readt=
able-parse-token *simple-readtable*)
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 buffer))))))
> > =A0 =A0 =A0 (eof-error-p (error 'end-of-file :stream stream))
> > =A0 =A0 =A0 (t eof-value))))
>
> > -----------------------------------------------------------------------=
---------
>
> > (with-open-file (input "simple-reader.lisp")
> > =A0 (loop
> > =A0 =A0 =A0:for sexp =3D (simple-read input nil input)
> > =A0 =A0 =A0:until (eq sexp input)
> > =A0 =A0 =A0:do (pprint sexp) (terpri)))
>
> > --
> > __Pascal Bourguignon__
>
>

By the way, here is in 1 line of BF, a complete BF reader that is able
to
read all the BF syntax needed to write it:

,+[-.,+]

Here's how to try it:

$ sudo apt-get install bf
$ cat > reader.bf
,+[-.,+]
$ bf reader.bf < reader.bf

Your 150 lines don't look very impressive now, do they?

Ruby < Lisp <<< BF!



In This Thread