[29158] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 402 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 3 18:10:25 2007

Date: Thu, 3 May 2007 15:09:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 3 May 2007     Volume: 11 Number: 402

Today's topics:
    Re: Dynamic DNS management <noozegoy@pookmail.com>
    Re: File::Grep <someone@example.com>
        Hash vs. Hash ref <rg.bacs@gmail.com>
    Re: Hash vs. Hash ref <xicheng@gmail.com>
    Re: Hash vs. Hash ref <mritty@gmail.com>
    Re: I find the perl syntax easier than python <rvtol+news@isolution.nl>
    Re: I find the perl syntax easier than python <abigail@abigail.be>
    Re: I find the perl syntax easier than python (aka ? the Platypus)
    Re: I find the perl syntax easier than python <abigail@abigail.be>
    Re: I find the perl syntax easier than python <bik.mido@tiscalinet.it>
    Re: I find the perl syntax easier than python <bik.mido@tiscalinet.it>
        remove html to leave text <ton_de_winter@yahoo.co.uk>
    Re: remove html to leave text <spamtrap@dot-app.org>
        selecting particular form with field <nospam@home.com>
    Re: selecting particular form with field <xicheng@gmail.com>
    Re: what is "}{"? <rvtol+news@isolution.nl>
    Re: what is "}{"? <abigail@abigail.be>
    Re: what is "}{"? <bik.mido@tiscalinet.it>
    Re: Why stay with lisp when there are python and perl? <xah@xahlee.org>
    Re: Why stay with lisp when there are python and perl? <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 03 May 2007 13:38:53 -0600
From: Nooze Goy <noozegoy@pookmail.com>
Subject: Re: Dynamic DNS management
Message-Id: <f1da7h01ebn@news1.newsguy.com>

Brian McCauley wrote:
> On May 3, 5:51 pm, Nooze Goy <nooze...@pookmail.com> wrote:
>> Brian McCauley wrote:
>>> On May 2, 12:42 am, Nooze Goy <nooze...@pookmail.com> wrote:
> 
> [ talking about a Unix shell script ]
> 
>>>> wget -O - --http-user=mylogin --http-passwd=myp455 'http://dynamic.zoneedit.com/auth/dynamic.html?host=my.domain.com'
>>>> In the script, the above line is repeated for each domain; each line
>>>> takes ten or fifteen seconds to process
> 
>>>> Obviously, with five or six domains, you're going to be hard-pressed to
>>>> update the IP every minute,
 >>>>
>>> Unless you spawn 5 or 6 wget commands at once.
>> How?
> 
> You are asking (in a Perl newsgroup) how, in a Unix shell script, to
> indicate that the script should not wait for one command to complete
> before going on to the next!
> 
> What's wrong with this picture?

There's nothing wrong with the picture - there's a flaw in your 
attitude. No question was asked about the script, but you chose to make 
a statement about it. Now you act amazed that there was a response to 
that...

Man, if you don't want to help, then don't answer. If you're going to 
change directions, then don't jump sh!tty when your direction is followed.

Basically, what's wrong is that YOU offered a response to a question 
that wasn't asked. You could have taken the few seconds to explain, but 
apparently you were too busy deconstructing my crappy little Perl script 
- which, as pathetic as it may be, does in fact work. Near as I could 
tell, the slowth is on the other end, at least through its current 
access method, but I thought perhaps someone else might be handling 
dyndns differently and have something useful to offer.

My mistake. Thanks, anyway.







------------------------------

Date: Thu, 03 May 2007 20:42:20 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: File::Grep
Message-Id: <MOr_h.6516$KN6.1625@edtnps89>

g4173c@motorola.com wrote:
> 
> I'm trying to get the match string from fgrep with the following code:
> 
> use File::Grep qw (fgrep);
> foreach $log (@logfile) {
>     @match = fgrep { /HOSTNAME/ } "$log";
>     ...
>    do_lots_more
> }
> 
> 
> however this is only returning a HASH(xxx). I assume it doesn't like
> the "$log" which is the path to the file. How can I correct this?

@ARGV = @logfile;

my @match;
while ( <> ) {
    push @match, $_ if /HOSTNAME/;
    }


Or if you want @match to contain log file names:

@ARGV = @logfile;

my @match;
while ( <> ) {
    if ( /HOSTNAME/ ) {
        push @match, $ARGV;
        close ARGV;
        }
    }





John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


------------------------------

Date: 3 May 2007 11:39:02 -0700
From: Rg <rg.bacs@gmail.com>
Subject: Hash vs. Hash ref
Message-Id: <1178217542.769713.218700@y80g2000hsf.googlegroups.com>

Saluton,

Please, take a look at the following Perl program:

-----------------------
#!/usr/bin/perl

use strict;

my $hash_ref = {
    List => ()
};

$hash_ref->{List}[0]->{Something} = "Boo";
$hash_ref->{List}[1]->{Something_else} = "Not boo";

print "Something is $hash_ref->{List}[0]{Something}\n";
print "Something else is $hash_ref->{List}[1]{Something_else}\n";
-----------------------

The output for this program is

"Something is Boo
Something else is Not boo"

I wonder why. How comes Perl treat $hash_ref->{List}[0] both as a hash
reference and a hash? Am I missing something here? Is there "undefined
behavior" involved?



------------------------------

Date: 3 May 2007 12:05:21 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: Hash vs. Hash ref
Message-Id: <1178219121.940711.45050@q75g2000hsh.googlegroups.com>

On May 3, 2:39 pm, Rg <rg.b...@gmail.com> wrote:
> Saluton,
>
> Please, take a look at the following Perl program:
>
> -----------------------
> #!/usr/bin/perl
>
> use strict;
>
> my $hash_ref = {
>     List => ()

ITYM:
    List => [ ],

> };
>
> $hash_ref->{List}[0]->{Something} = "Boo";
> $hash_ref->{List}[1]->{Something_else} = "Not boo";
>
> print "Something is $hash_ref->{List}[0]{Something}\n";
> print "Something else is $hash_ref->{List}[1]{Something_else}\n";
> -----------------------
>
> The output for this program is
>
> "Something is Boo
> Something else is Not boo"
>
> I wonder why. How comes Perl treat $hash_ref->{List}[0] both as a hash
> reference and a hash? Am I missing something here? Is there "undefined
> behavior" involved?

no, they are both references, check what's the difference between:

 $hash_ref->{List}[0]{something}
 $hash_ref->{List}[0]->{something}

Read "Intermediate Perl" section 4.7

Regards,
Xicheng



------------------------------

Date: 3 May 2007 15:05:15 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Hash vs. Hash ref
Message-Id: <1178229915.741108.206090@p77g2000hsh.googlegroups.com>

On May 3, 2:39 pm, Rg <rg.b...@gmail.com> wrote:
> Saluton,
>
> Please, take a look at the following Perl program:
>
> -----------------------
> #!/usr/bin/perl
>
> use strict;
>
> my $hash_ref = {
>     List => ()

This doesn't do what you think it does.  ALWAYS enable warnings when
writing Perl code!!

>
> };
>
> $hash_ref->{List}[0]->{Something} = "Boo";
> $hash_ref->{List}[1]->{Something_else} = "Not boo";
>
> print "Something is $hash_ref->{List}[0]{Something}\n";
> print "Something else is $hash_ref->{List}[1]{Something_else}\n";
> -----------------------
>
> The output for this program is
>
> "Something is Boo
> Something else is Not boo"
>
> I wonder why. How comes Perl treat $hash_ref->{List}[0] both as a hash
> reference and a hash?

What gives you the impression anything in the above is indicating
that?  The second arrow and lack thereof?

> Am I missing something here?

Yes.  The "arrow rule".  You should read up on how multidimensional
structures are accessed in Perl.  Take a look at :
perldoc perlreftut
perldoc perllol
perldoc perldsc.

> Is there "undefined behavior" involved?

Not at all.  It's perfectly well defined.  It's your assumption that
is in error.

Paul Lalli



------------------------------

Date: Thu, 3 May 2007 21:08:26 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: I find the perl syntax easier than python
Message-Id: <f1dj0d.1cs.1@news.isolution.nl>

Michele Dondi schreef:
> grocery_stocker:

>>    print "$value \n";
> 
> BTW: what is it, with that space?

RFC 2646
;)

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: 03 May 2007 19:21:12 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: I find the perl syntax easier than python
Message-Id: <slrnf3kdgg.hl5.abigail@alexandra.abigail.be>

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCMXCII September
MCMXCIII in <URL:news:7vqh339jps8hbki5biisah7iaf0nlctdcn@4ax.com>:
\\  
\\  Since I mentioned Perl 6 above, in it eventually we will have more
\\  convenient ways and less ambiguity in passing parameters. We will
\\  still be able to use @_ & C. but who does really need them when you
\\  can do
\\  
\\    sub addprint ($n,$m) { say $n+$m }  # ?

And this is an advantage? Limiting yourself to two arguments?

In Perl5, you aren't tempted to use named variables, so you get
your arguments in an array. And given an array, it's natural to
allow a variable number of arguments:


    sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}


Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


------------------------------

Date: Thu, 03 May 2007 21:02:45 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: I find the perl syntax easier than python
Message-Id: <slrnf3kk20.o5h.dformosa@localhost.localdomain>

On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote:

> In Perl5, you aren't tempted to use named variables, so you get
> your arguments in an array. And given an array, it's natural to
> allow a variable number of arguments:
>
>
>     sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}

So you do something like this

sub addprint (*@num) { say [+] @num };



------------------------------

Date: 03 May 2007 21:12:37 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: I find the perl syntax easier than python
Message-Id: <slrnf3kk1c.hl5.abigail@alexandra.abigail.be>

David Formosa (aka ? the Platypus) (dformosa@usyd.edu.au) wrote on
MMMMCMXCIII September MCMXCIII in <URL:news:slrnf3kk20.o5h.dformosa@localhost.localdomain>:
^^  On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote:
^^  
^^ > In Perl5, you aren't tempted to use named variables, so you get
^^ > your arguments in an array. And given an array, it's natural to
^^ > allow a variable number of arguments:
^^ >
^^ >
^^ >     sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}
^^  
^^  So you do something like this
^^  
^^  sub addprint (*@num) { say [+] @num };


Yeah, but that's only on the second try. ;-)


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15 =>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hacker/


------------------------------

Date: Thu, 03 May 2007 23:41:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: I find the perl syntax easier than python
Message-Id: <g7lk33h51ljljhsi7p83g7qhfmj120n6de@4ax.com>

On 03 May 2007 19:21:12 GMT, Abigail <abigail@abigail.be> wrote:

>\\    sub addprint ($n,$m) { say $n+$m }  # ?
>
>And this is an advantage? Limiting yourself to two arguments?

Well, you know perfectly well that this is an *artificial* example to
mimic the OP's one. But yes, it's there for those cases in which I
*do* want to limit myself to two arguments, and perhaps type check
them.

>In Perl5, you aren't tempted to use named variables, so you get
>your arguments in an array. And given an array, it's natural to

I can't believe you're implicitly assuming that those guys aren't
thinking of letting you do that in Perl 6 too, and more.

>allow a variable number of arguments:
>
>    sub addprint {my $sum = 0; $sum += $_ for @_; print $sum, "\n"}

Funny, in Perl 6 that could be

    sub addprint {say [+] @_}


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Thu, 03 May 2007 23:45:03 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: I find the perl syntax easier than python
Message-Id: <mtlk33ptfdohop2qcqipp7pvas9r1a1r5q@4ax.com>

On Thu, 03 May 2007 21:02:45 GMT, "David Formosa (aka ? the Platypus)"
<dformosa@usyd.edu.au> wrote:

>So you do something like this
>
>sub addprint (*@num) { say [+] @num };

D'Oh, you beat me. But in my example I showed our friend Abigail that
if you really want you still have @_.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 3 May 2007 13:51:12 -0700
From: ton de w <ton_de_winter@yahoo.co.uk>
Subject: remove html to leave text
Message-Id: <1178225472.621341.282980@p77g2000hsh.googlegroups.com>

Hello,

I am using DBI::msql to fetch some stuff.and then write it out as CSV
and it is picked up by openoffice.Calc
This works perfect - except one of the text fields includes html tags
as wella s useful text.
How can I strip out the html tags <b> etc etc and replace each tag
with a char of my choice?

TIA

Ton



------------------------------

Date: Thu, 03 May 2007 17:16:13 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: remove html to leave text
Message-Id: <m2tzutzjz6.fsf@local.wv-www.com>

ton de w <ton_de_winter@yahoo.co.uk> writes:

> How can I strip out the html tags <b> etc etc and replace each tag
> with a char of my choice?

That's a Frequently Asked Question:

    perldoc -q 'remove HTML'

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Thu, 03 May 2007 21:12:01 GMT
From: "Nospam" <nospam@home.com>
Subject: selecting particular form with field
Message-Id: <Bes_h.1732$r4.1693@newsfe1-gui.ntli.net>

If I have several forms on a page, can someone confirm, if this would
select/follow the first form with the field username, and set the username
field to username:

#!usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new();
my $url= 'http://www.example.com';
$mech->get($url);
 my @forms = grep {$_->$mech->field()=~ /username/i }$mech->forms();
$mech->form($form[0]);
$mech->field('username','username');




------------------------------

Date: 3 May 2007 14:33:04 -0700
From: Xicheng Jia <xicheng@gmail.com>
Subject: Re: selecting particular form with field
Message-Id: <1178227984.721178.270770@n59g2000hsh.googlegroups.com>

On May 3, 5:12 pm, "Nospam" <nos...@home.com> wrote:
> If I have several forms on a page, can someone confirm, if this would
> select/follow the first form with the field username, and set the username
> field to username:
>
> #!usr/bin/perl
> use strict;
> use warnings;
> use WWW::Mechanize;
>
> my $mech = WWW::Mechanize->new();
> my $url= 'http://www.example.com';
> $mech->get($url);
>  my @forms = grep {$_->$mech->field()=~ /username/i }$mech->forms();
> $mech->form($form[0]);


> $mech->field('username','username');

How about:

  my $theform = $mech->form_with_fields('username');
  theform->attr('username', 'username') if defined $theform;

(untested)

Regards,
Xicheng



------------------------------

Date: Thu, 3 May 2007 21:29:11 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: what is "}{"?
Message-Id: <f1dk95.1d0.1@news.isolution.nl>

zenny lenny schreef:

> 1. This code adds a column of numbers:  perl -lne '$x+=$_}{print $x;'
> 
> What is the purpose of "}{"?

Try -MO=Deparse like this:

  perl -MO=Deparse -ne'$x+=$_}{print $x'

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: 03 May 2007 20:50:55 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: what is "}{"?
Message-Id: <slrnf3kiok.hl5.abigail@alexandra.abigail.be>

zenny lenny (zennylenny@gmail.com) wrote on MMMMCMXCII September MCMXCIII
in <URL:news:1178127598.567833.260790@y80g2000hsf.googlegroups.com>:
==  
==  
==  What is the purpose of "}{"?
==  


Self reflection.  Do you see a vase, or two faces looking at each other?



Abigail
-- 
print v74.117.115.116.32.97.110.111.116.104.101.114.
      v32.80.101.114.108.32.72.97.99.107.101.114.10;


------------------------------

Date: Thu, 03 May 2007 23:47:39 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: what is "}{"?
Message-Id: <d3mk331em25d4s3km6cgs7mm104dp7aavj@4ax.com>

On 03 May 2007 20:50:55 GMT, Abigail <abigail@abigail.be> wrote:

>==  What is the purpose of "}{"?
>==  
>
>
>Self reflection.  Do you see a vase, or two faces looking at each other?

A yo-yo. With no string.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 3 May 2007 12:15:32 -0700
From: Xah Lee <xah@xahlee.org>
Subject: Re: Why stay with lisp when there are python and perl?
Message-Id: <1178219732.127815.3260@y80g2000hsf.googlegroups.com>

Nameless wrote:
=C2=AB
Python has readable syntax, a huge library, and bindings for what
seems like every major in linux. Perl has CPAN. It seems with those
languages if you want to do something all you have to do is import
functionality from a library someone had written and use that.

In lisp you'd have to "roll your own".

Why should I keep on learning lisp when there are python and perl?
=C2=BB

You question is a valid question. Unfortunately, so far in the 14
replies in the thread, vast majority are one-liner drivels from
reactionary lisp fuckheads, many of which long time dwellers of
comp.lang.lisp.  A common scene in any programing newsgroup. They feel
attacked, reasonably by your irrespective and incentive tone, and they
have the need to sputter drivel back, to entertain themselves. (I wish
perl and python programers take a glimpse of that thread to realize
what computing factions are driveling behind each other's back)

Although your message is written in a taunting style, but it has a
valid point, and in fact is a Frequently Ask Question among the vast
majority of programers in the computing industry. Namely, today,
languages like Perl, PHP, and to a lesser degree Python, are so
popular, and ubiquitous, widely deployed and widely demanded in the
job market, and also, that these languages in general and in
comparison to Lisp, have far wide library support and as well as
community support, and also, that these comparatively young languages
are relatively high-level modern languages, that they are at a level
above C, Java, making them ideal for saving programer's time as does
lisp.

So, what are some reasons, if any, should today's programer invest
time into another language lisp (especially it has trivial percentage
in programing job market), while not using the time, to perhaps master
a industrial language they already know, such as Perl, or even venture
into another language like Python, PHP or the new kid on the block
Ruby?

So far, =E2=80=9CD Herring=E2=80=9D and =E2=80=9Cfireblade/bobi=E2=80=9D ha=
s given their personal take
on this question.  Lars Rune N=C3=B8stdal, provided a link
http://wiki.alu.org/The_Road_to_Lisp_Survey that details lispers's
stories on why lispers lisp.

Please allow me to give my take, and i believe it is a most important
_technical_ reason, why, Perl, Python, etc languages today simply
cannot replace lisp. And why, if you are a programer with serious
intention of refining your craft, then learning lisp is a good
investment. (one non-technical reason in learning lisp, is that the
widely popular programer's text editor emacs has lisp embedded as its
extension language. As a coder, knowing emacs and lisp, will enpower
you greatly in the long term.)

I think the one most important techincal aspect, that lisp is in fact
superior and cannot be replaced by the current crop of high-level
languages, is the peculiar fact that the language deals with symbols.
Namely, sometimes called symbolic computing.

I have written a exposition on this issue before. It is archived at
this page:
=E2=80=9CWhat is Expressiveness in a Computer Language=E2=80=9D
http://xahlee.org/perl-python/what_is_expresiveness.html
at the section Symbolic Computation.

There are many =E2=80=9Cpapers=E2=80=9D or articles that address the questi=
on of what
does it mean when someone says lisp is a symbolic language. In my
opnion, they are all fuzzy, or filled with academic jargons that is
practically and most likely theoretically useless. In the following
exposition, you will see what lisp's =E2=80=9Csymbolic computation=E2=80=9D=
 in a way
that makes you understand.

I excerpt the section below.

SYMBOLIC COMPUTATION

Lisp differs from most imperative programing languages in that it
deals with symbols. What does this mean?

In imperative languages, a value can be assigned a name, and this name
is called a variable. For example, =E2=80=9Cx=3D3=E2=80=9D, and whenever th=
is =E2=80=9Cname=E2=80=9D is
encountered, it is evaluated to its value. It does not make any sense,
to have variables without a assigned value. That is, the =E2=80=9Cx=E2=80=
=9D is not
useful and cannot be used until you assign something to it.

However, in lisp, there is a concept of Symbols. As a way of
explanation, a =E2=80=9Cvariable=E2=80=9D needs not to be something assigne=
d of a
value. Symbols can stand by themselves in the language. And, when a
symbol is assigned a value, the symbol can retain its symbolic form
without becoming a value.

This means that in lisp, =E2=80=9Cvariables=E2=80=9D can be manipulated in =
its un-
evaluated state. The situation is like the need for the =E2=80=9Cevaluate=
=E2=80=9D
command in many languages, where the programer can built code as
strings and do =E2=80=9Cevaluate(myCodeString)=E2=80=9D to achieve meta-pro=
graming.

For example, in imperatives languages once you defined =E2=80=9Cx=3D3=E2=80=
=9D, you
cannot manipulate the variable =E2=80=9Cx=E2=80=9D because it gets evaluate=
d to 3
right away. If you want, you have to build a string =E2=80=9C"x"=E2=80=9D a=
nd
manipulate this string, then finally use something like
=E2=80=9Cevaluate(myCodeString)=E2=80=9D to achieve the effect. If the impe=
rative
language does provide a =E2=80=9Cevaluate()=E2=80=9D function, its use brea=
ks down
quickly because the language is not designed for doing it. It's
extremely slow, and impossible to debug, because there lacks
facilities to deal with such meta programing.

In lisp, variable's unevaluated form are always available. One just
put a apostrophe ' in front of it. In =E2=80=9Cx=3D3=E2=80=9D, the x is a v=
ariable in
the contex of the code logic, x is a name of the variable in the
context of meaning analysis, and x is a symbol in the context of the
programing language. This Symbols concept is foreign to imperative
languages. It is also why lisp are known as symbolic languages. Such
makes meta-programing possible.

The power of symbolic processing comes when, for example, when you
take user input as code, or need to manipulate math formulas, or
writing programs that manipulates the source code, or generate
programs on the fly. These are often needed in advanced programing
called Artificial Intelligence. This is also the reason, why lisp's
=E2=80=9Cmacro=E2=80=9D facility is a powerful feature unlike any so-called=
 =E2=80=9Cpre-
processors=E2=80=9D or =E2=80=9Ctemplates=E2=80=9D in imperative languages.

Mathematica for example, is sometimes known as a Computer Algebra
System. It too, works with symbols in the language. They can be
manipulated, transformed, assigned a value, evaluated, hold
unevaluated etc.

One way for a imperative programer to understand symbols, is to think
of computing with strings, such as which Perl and Python are well
known for. With strings, one can join two strings, select sub strings,
use string pattern (regex) to transform strings, split a string into a
list for more powerful manipulation, and use =E2=80=9Cevaluate()=E2=80=9D t=
o make the
string alive. Now imagine all these strings need not be strings but as
symbols in the language, where the entire language works in them and
with them, not just string functions. That is symbolic computation.

Here we see, a expressibility unseen in non-lisp family of languages.

--------------------------
End excerpt.

(if there is some demand, i will add a concrept, little programing
example, that shows, how lisp's symbols and macros concepts, set it
apart from new scripting languages)

This lisp's symbol concept, as far as i know, does not exist in some
other high-level functional programing languages such as Haskell. I'm
not familiar with many functional languages except Lisp and
Mathematica. I'm curious, as to how Haskell, which itself is quite
with capable of symbolic computation i think, deals with it even
though the language doesn't employ the concep of lisp's symbols per
se.

  Xah
  xah@xahlee.org
=E2=88=91 http://xahlee.org/



------------------------------

Date: Thu, 03 May 2007 21:53:32 +0200
From: Markus E Leypold <development-2006-8ecbb5cc8aREMOVETHIS@ANDTHATm-e-leypold.de>
Subject: Re: Why stay with lisp when there are python and perl?
Message-Id: <aiejlx65vn.fsf@hod.lan.m-e-leypold.de>


Xah Lee <xah@xahlee.org> writes:

> (if there is some demand, i will add a concrept, little programing

No. There ain't.

- M



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 402
**************************************


home help back first fref pref prev next nref lref last post