[28097] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9461 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 13 11:05:56 2006

Date: Thu, 13 Jul 2006 08:05:07 -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, 13 Jul 2006     Volume: 10 Number: 9461

Today's topics:
        "Learning Perl" book <tuo_pe@yahoo.com>
    Re: "Learning Perl" book <vtatila@mail.student.oulu.fi>
    Re: "Learning Perl" book <tuo_pe@yahoo.com>
    Re: "Learning Perl" book rajeev.networld@gmail.com
    Re: "Learning Perl" book <penryu@saiyix.ath.cx>
    Re: "Learning Perl" book <simon.chao@fmr.com>
    Re: "Learning Perl" book <sherm@Sherm-Pendleys-Computer.local>
    Re: Capture a frame from AVI/MOV pjsenthil@gmail.com
    Re: Dereferencing Hash of Arrays anno4000@radom.zrz.tu-berlin.de
        Find a line in an html file starfrit@gmail.com
    Re: Find a line in an html file <xicheng@gmail.com>
    Re: Inline missing with ActiveState? <bol@adv.magwien.gv.at>
    Re: Lama Vs. Camel, How Much Camel in Perl Docs? (Was:  <vtatila@mail.student.oulu.fi>
        problem with time stamp davide.papagno@gmail.com
    Re: problem with time stamp <tony_curtis32@_NOSPAM_yahoo.com>
    Re: problem with time stamp davide.papagno@gmail.com
    Re: problem with time stamp <tony_curtis32@_NOSPAM_yahoo.com>
    Re: Question on "if" statement <bol@adv.magwien.gv.at>
        RegEx and AND <tinu.downunder@gmail.com>
    Re: RegEx and AND <mritty@gmail.com>
    Re: RegEx and AND <xicheng@gmail.com>
    Re: RegEx and AND <sherm@Sherm-Pendleys-Computer.local>
    Re: unexpected error with Exporter anno4000@radom.zrz.tu-berlin.de
    Re: unexpected error with Exporter <bol@adv.magwien.gv.at>
    Re: What is a type error? <jo@durchholz.org>
    Re: What is a type error? <jo@durchholz.org>
    Re: What is a type error? <jo@durchholz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Jul 2006 13:43:41 +0300
From: Tuomas <tuo_pe@yahoo.com>
Subject: "Learning Perl" book
Message-Id: <44b623e5$0$22371$39db0f71@news.song.fi>

Hi!

I am teaching myself perl, and I have the book "Learning Perl, 2.ed". Is 
this edition now considered outdated since the third edition has been 
published? In other words, should I buy the new book?

Thanks!

Tuomas


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

Date: Thu, 13 Jul 2006 13:58:10 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: "Learning Perl" book
Message-Id: <e95908$s12$1@news.oulu.fi>

Tuomas wrote:
> I am teaching myself perl, and I have the book "Learning Perl, 2.ed". Is
> this edition now considered outdated since the third edition

Hi,
Actually there's already a 4th edition out there. See:

http://tinyurl.com/obtxp

The 2nd ed is out of date in places, I think. It doesn't cover using 
warnings, diagnostics, doesn't use lexical variables all that much and so 
on. Most of the basics are valid still and the 2nd ed was the book with 
which I started roughly two years back,  I think. It covers some older stuff 
that isn't used much or delt with in the 4th ed any more, like formats and 
dbm files, if you are interested in those.

I would say that the 2nd ed is a nice start but should not be your only PErl 
book. The 4th edition is clearer and more up to date. You should also get a 
more advanced book at some point about references, packages, object-oriented 
programming and so on. A logical choice would be the "sequel" to Learning 
Perl called Intermediate Perl:

http://tinyurl.com/qf5sf

hope this helps.

PS: Both links given here point to amazon.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/ 




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

Date: Thu, 13 Jul 2006 14:31:31 +0300
From: Tuomas <tuo_pe@yahoo.com>
Subject: Re: "Learning Perl" book
Message-Id: <44b62f13$0$22344$39db0f71@news.song.fi>

Veli-Pekka Tätilä wrote:
> hope this helps.
> 
It did! :-) Thanks.

T


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

Date: 13 Jul 2006 05:14:22 -0700
From: rajeev.networld@gmail.com
Subject: Re: "Learning Perl" book
Message-Id: <1152792862.294449.209330@m79g2000cwm.googlegroups.com>

I would recommend you using "Programming Perl". That is real guide
book.

Tuomas wrote:
> Veli-Pekka T=E4til=E4 wrote:
> > hope this helps.
> >=20
> It did! :-) Thanks.
>=20
> T



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

Date: Thu, 13 Jul 2006 13:53:15 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: "Learning Perl" book
Message-Id: <slrnebck2b.vd6.penryu@ruri.saiyix>

rajeev.networld@gmail.com <rajeev.networld@gmail.com> wrote:
> I would recommend you using "Programming Perl". That is real guide
> book.

I've had limited success using "Programming Perl" to teach (and/or
learn) Perl.  Though after a good grasp of the langauge is acquired,
it is invaluable.

YMMV,
Tim


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

Date: 13 Jul 2006 07:14:20 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: "Learning Perl" book
Message-Id: <1152800060.624793.112160@75g2000cwc.googlegroups.com>


Tim Hammerquist wrote:
> rajeev.networld@gmail.com <rajeev.networld@gmail.com> wrote:
> > I would recommend you using "Programming Perl". That is real guide
> > book.
>
> I've had limited success using "Programming Perl" to teach (and/or
> learn) Perl.  Though after a good grasp of the langauge is acquired,
> it is invaluable.


I agree with Tim. I'd recommend the Perl Cookbook for learning Perl. Of
course, the choice of texts is dependent alot upon learning style. I
happen to learn by example much more rapidly and thoroughly than by
reading through an instructional text (although typically the authors
of Perl instructional texts--that I'm familiar with--write with a
certain verve that makes it less dry than other instructional texts).

Once you cut your teeth on the Cookbook, Programming Perl is a great
reference. (It's great for airport reading). Also, don't forget perldoc.



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

Date: Thu, 13 Jul 2006 10:33:27 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: "Learning Perl" book
Message-Id: <m24pxld16w.fsf@Sherm-Pendleys-Computer.local>

rajeev.networld@gmail.com writes:

> I would recommend you using "Programming Perl". That is real guide
> book.

The Camel is a reference - you can get started with that if you're already
familiar with one (or more) of the languages that influenced Perl's design,
like C, sed, or awk.

But if you're new to programming, or your only previous programming was in
a language that's very dissimilar to Perl, then the Llama is the way to go.

Calling one or the other "the real guide book" is just foolish. They have
different goals and are aimed at different audiences. Each serves its target
audience very well.

sherm--

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


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

Date: 13 Jul 2006 05:17:37 -0700
From: pjsenthil@gmail.com
Subject: Re: Capture a frame from AVI/MOV
Message-Id: <1152793056.984739.91640@p79g2000cwp.googlegroups.com>

Thanx For your reply..I am able to get a single frame.as u have told..

And now i am not able to idea.how to embed it into a webpage .

actually my idea was to embed it on my page and play video and when he
want a particular frame he can get that frame.

so how can i control the Mplayer from my perl code .is there and
package for it to do..
ie the commmand line how can i invoke from perl script.
Regards
Senthil

Vilmos Soti wrote:
> pjsenthil@gmail.com writes:
>
> > I read the mplayer. there is option like converting the whole video
> > file into frames..but not the required frame.
>
> This is how I extract a specific frame through mplayer:
>
> mplayer -vo jpeg -ao null -ss $icon_time -frames 2 avifile.avi
>
> Check the -ss switch in the manpage. You might also want to check
> the -vo switch, and use png instead of jpeg depending on your needs.
>
> You need to extract 2 frames, since the first will be the very
> first frame of the video, and the second one is the one you need.
>
> > That option is also there "grab_frame" but it is not implemented.
>
> Where is it? In the source? I couldn't find it in the manpage.


******And regarding the grab frame option ..it is given in
slave.txt.*******


> 
> Vilmos



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

Date: 13 Jul 2006 10:54:04 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Dereferencing Hash of Arrays
Message-Id: <4hmn2cFadneU1@news.dfncis.de>

Paul Lalli <mritty@gmail.com> wrote in comp.lang.perl.misc:
> Jennifer I. Drake wrote:

[good advice snipped]

> Why are you undef'ing %data?  If you want %data to go away at this
> point so you get a new blank version of it next time through your loop,
> then properly scope your variables.  Declare `my %data` in the smallest
> scope in which it is needed.  At the end of that scope, before the next
> iteration begins, %data will be destroyed and your next iteration will
> create a brand new version of it.

This isn't quite correct.  Nothing happens at the end of a loop body
to the lexical variables defined in its scope.  Only when the my()
statement is passed at run time is a new variable created.  The effect
is largely the same, but there is no action-at-a-distance as your
explanation implies.

Anno


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

Date: 13 Jul 2006 07:25:16 -0700
From: starfrit@gmail.com
Subject: Find a line in an html file
Message-Id: <1152800716.778150.170470@75g2000cwc.googlegroups.com>

I'm trying to addapt a perl script with another version of my hockey
simulator, because the file name structure as changed.  It is an IF
that looks for a link into an html file

Before, the link was
<A HREF=AHSQ79.html> and the perl  line was if (m/^<A
HREF.(\w*.\w+)>.(\d+).*/)

Now, the link is  <a href="AHSQ2006-79.html">

Thanks for any help



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

Date: 13 Jul 2006 07:39:52 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Find a line in an html file
Message-Id: <1152801591.999245.137720@b28g2000cwb.googlegroups.com>

starfrit@gmail.com wrote:
> I'm trying to addapt a perl script with another version of my hockey
> simulator, because the file name structure as changed.  It is an IF
> that looks for a link into an html file
>
> Before, the link was
> <A HREF=AHSQ79.html> and the perl  line was if (m/^<A
> HREF.(\w*.\w+)>.(\d+).*/)
>
> Now, the link is  <a href="AHSQ2006-79.html">
>
> Thanks for any help

    if (/^<a href="([^"]*)">.(\d+)/i) { ... }

Xicheng



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

Date: Thu, 13 Jul 2006 14:17:09 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: Inline missing with ActiveState?
Message-Id: <1152793030.605428@proxy.dienste.wien.at>

Robert Hicks:

> You add that in your PPM session:
>
> ppm> rep add theoryx <URL from above>
>
> That will add that repository to your PPM sessions and you will have
> "Inline".

OK, I got Inline now. Many thanks for your help!

Greetings, Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

Date: Thu, 13 Jul 2006 16:45:22 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Lama Vs. Camel, How Much Camel in Perl Docs? (Was: "Learning Perl" book)
Message-Id: <e95ipo$tt2$1@news.oulu.fi>

rajeev.networld@gmail.com wrote:
<top-post corrected>
> I would recommend you using "Programming Perl". That is real guide
> book.
Hi Rajeev,
About Programming Perl Vs Learning Perl and Intermediate Perl. It depends on 
how experienced you are,  how you like to learn and what level of depth is 
enough. Of course I would recommend getting all three books and no matter 
what, picking up the Camel sooner or later. But personally, I wouldn't start 
with the Camel and I got the impression the OP liked Learning Perl (known as 
the Lama book):

Even though I had programmed in other languages before (Java and C), I found 
approaching the Camel book very difficult, initially. I've always liked the 
tone (esp. humor) in it but kind of got lost in to the gorry details failing 
to get the big picture. After having read some other Perl books first I 
revisited Programming Perl. I still don't find it an easy read, but it is a 
great reference if I have to look up something particular especially 
something obscure.

As to what style appeals to me, personally I like to start with the very 
practical the style in many Sams books comes to mind, though I do realize it 
is not for everyone. After having gotten the basics right, something less 
verbose and thought provoking would be good, too. I didn't like K&R much 
when I started C, and neither was I fond of the Camel Wehn I started Perl. 
But both books get better and better the more you learn.  K&R, for instance, 
tels me how hashes, central in Perl, could be implemented.

All this reminds me of an observation I've made:
In reading some Perl docs followed by Programming Perl's take on the 
subject, there are sentences that are very close to each other, as though 
the Perl docs were influenced by the Camel rather heavily. Well Larry Wall 
created the language so there's nothing wrong in that. But I wonder how 
large a portion of the current Perl docs have been written by Larry Wall or 
the rest of the Camel authors? Unlike modules and pragmata many of the core 
docs, detailing how the language works in reference fashion, have no author 
information included.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/ 




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

Date: 13 Jul 2006 06:19:23 -0700
From: davide.papagno@gmail.com
Subject: problem with time stamp
Message-Id: <1152796763.356172.148490@i42g2000cwa.googlegroups.com>

Hi all.
I use this command to get the time stamp file output

$date = ctime(stat($file)->mtime);

and what I get is:

Wed Apr  5 16:44:43 2006

is there a simple way to get only

Wed Apr  5 
?

really thanx all



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

Date: 13 Jul 2006 09:21:24 -0400
From: Tony Curtis <tony_curtis32@_NOSPAM_yahoo.com>
Subject: Re: problem with time stamp
Message-Id: <y6zsodvt8wtn.fsf@post.queensu.ca>

>> On 13 Jul 2006 06:19:23 -0700,
>> davide.papagno@gmail.com said:

> Hi all.  I use this command to get the time stamp file
> output

> $date = ctime(stat($file)->mtime);

> and what I get is:

> Wed Apr 5 16:44:43 2006

> is there a simple way to get only

> Wed Apr 5 ?

Look up strftime in "perldoc POSIX".

hth
t


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

Date: 13 Jul 2006 07:08:07 -0700
From: davide.papagno@gmail.com
Subject: Re: problem with time stamp
Message-Id: <1152799687.704824.136280@m73g2000cwd.googlegroups.com>

Yeah Tony, it seems is great

$now = strftime "%a %b %d", gmtime;
print "$now\n";

But I have to get the time stamp of a file $file.
I don't know how to match strftime  and stat function

Tony Curtis ha scritto:

> >> On 13 Jul 2006 06:19:23 -0700,
> >> davide.papagno@gmail.com said:
>
> > Hi all.  I use this command to get the time stamp file
> > output
>
> > $date = ctime(stat($file)->mtime);
>
> > and what I get is:
>
> > Wed Apr 5 16:44:43 2006
>
> > is there a simple way to get only
>
> > Wed Apr 5 ?
> 
> Look up strftime in "perldoc POSIX".
> 
> hth
> t



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

Date: 13 Jul 2006 10:25:57 -0400
From: Tony Curtis <tony_curtis32@_NOSPAM_yahoo.com>
Subject: Re: problem with time stamp
Message-Id: <y6zsk66h8tu2.fsf@post.queensu.ca>

>> On 13 Jul 2006 07:08:07 -0700,
>> davide.papagno@gmail.com said:

> Yeah Tony, it seems is great $now = strftime "%a %b %d",
> gmtime; print "$now\n";

> But I have to get the time stamp of a file $file.  I
> don't know how to match strftime and stat function

Ah well, couldn't give it all away, could I? :-)

    localtime()

hth
t


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

Date: Thu, 13 Jul 2006 13:00:37 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: Question on "if" statement
Message-Id: <1152788439.868472@proxy.dienste.wien.at>

Huub:

> $plaats[0] = @plaats;

This will write the # of elements of the array @plaats into its first
element. Are you sure that you want to do this?

If you want to access the first element of @plaats, you can use
$plaats[0] immediately, without this assignment.

> if ($plaats[0] == 'Londen')

'==' is for numerical comparisions only. You should use 'eq' here.

> $plaats[0] = @plaats;
> unless ($plaats[0] == 'Londen')

See above.

> I've been searching through CPAN and have tried with and without
> brackets and/or quotes, @ instead of $, with and without [0], but I
> can't get it right. Where am I going wrong?

Perhaps your forgot to read some docs? Like perldata and perlop? ;-)

BTW: I'd suggest to add a 'use warnings;' in front of your script.

Greetings, Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

Date: 13 Jul 2006 05:29:52 -0700
From: "tinu" <tinu.downunder@gmail.com>
Subject: RegEx and AND
Message-Id: <1152793792.070359.102800@b28g2000cwb.googlegroups.com>

Hi All

I need to do a simple RegEx expression for and AND. I dont know how to
do this.
I have the following string:
"The tree is taller then the flower".

I would like to search for "tree" AND "flower". How Do I do this?

Thanks for your help



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

Date: 13 Jul 2006 05:35:26 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: RegEx and AND
Message-Id: <1152794126.213622.247780@75g2000cwc.googlegroups.com>

tinu wrote:
> I need to do a simple RegEx expression for and AND. I dont know how to
> do this.
> I have the following string:
> "The tree is taller then the flower".
>
> I would like to search for "tree" AND "flower". How Do I do this?

Why are you assuming you need one regexp?  Why can't you do:

my $line = "The tree is taller than the flower."
if ($line =~ /tree/ && $line =~ /flower/) { ... }

I suppose if you really wanted one regexp, you could so something
bizarre like:
if ($line =~ /tree.*flower|flower.*tree/) { ... }
to account for the possibility that the words are in either order. . .

Paul Lalli



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

Date: 13 Jul 2006 06:07:36 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: RegEx and AND
Message-Id: <1152796056.901195.84350@75g2000cwc.googlegroups.com>

tinu wrote:
> Hi All
>
> I need to do a simple RegEx expression for and AND. I dont know how to
> do this.
> I have the following string:
> "The tree is taller then the flower".
>
> I would like to search for "tree" AND "flower". How Do I do this?
>
> Thanks for your help

  if ($line =~ /^(?=.*tree)(?=.*flower)/) { ... }

Xicheng



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

Date: Thu, 13 Jul 2006 10:35:31 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: RegEx and AND
Message-Id: <m2zmfdbmj0.fsf@Sherm-Pendleys-Computer.local>

"Paul Lalli" <mritty@gmail.com> writes:

> tinu wrote:
>> I need to do a simple RegEx expression for and AND. I dont know how to
>> do this.
>> I have the following string:
>> "The tree is taller then the flower".
>>
>> I would like to search for "tree" AND "flower". How Do I do this?
>
> Why are you assuming you need one regexp?

I'd guess that's what the instructor said to do - this smells like homework
to me.

sherm--

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


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

Date: 13 Jul 2006 10:09:47 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: unexpected error with Exporter
Message-Id: <4hmkfbFa0ulU1@news.dfncis.de>

Daniel <dcutter@gmx.de> wrote in comp.lang.perl.misc:
> I've got quite a large programme that's working just fine except for a
> few minor bugs and several design flaws. So I've decided to clean it up
> a bit. It uses several self-written objects and modules, so I thought a
> good way to start would be to put them in a sub directory. But I get an
> error: "Undefined subroutine &main::d1 called at a.pl...". I've reduced
> everything down to this:
> 
> #### main programme (./a.pl)
> #!perl
> use strict;
> use warnings;
> use bb;
> use cc::dd;

This tries to import functions from cc::dd.  Since there
is no such package, nothing is imported.

> b1();
> d1();
> 
> #### module bb (./bb.pm)
> package bb;
> use strict;
> use warnings;
> use Exporter;
> our @ISA = qw(Exporter);
> our @EXPORT = qw(b1);
> 
> sub b1 { print "b1\n" }
> 1;
> 
> #### module dd in local sub directory cc (./cc/dd.pm)
> package dd;

Change this to

    package cc::dd;

> use strict;
> use warnings;
> use Exporter;
> our @ISA = qw(Exporter);
> our @EXPORT = qw(d1);
> 
> sub d1 { print "d1\n" }
> 1;

[snip]

Anno


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

Date: Thu, 13 Jul 2006 13:33:58 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: unexpected error with Exporter
Message-Id: <1152790439.188613@proxy.dienste.wien.at>

Daniel:

> #### module dd in local sub directory cc (./cc/dd.pm)
> package dd;

This is the problem - the package hierarchy should always
be the same as the directory hierarchy - so you should write

package cc::dd;

here, and everything will be fine.

The reason: if you write

use cc:dd;

Perl will try to invoke the modules 'import' method

cc::dd->import();

and because there is no such method, will look into the
array @cc::dd::ISA, which does not exist (only @dd::ISA
does). Therefore, the 'import' method of Exporter will
not be inherited, and so d1 will not get exported into
package 'main'.

Greetings, Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

Date: Thu, 13 Jul 2006 12:37:12 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e9581q$6od$1@online.de>

Marshall schrieb:
> Joachim Durchholz wrote:
>> Marshall schrieb:
>>> Joachim Durchholz wrote:
>>>> Marshall schrieb:
>>>>> I can see the lack of a formal model being an issue, but is the
>>>>> imperative bit really all that much of an obstacle? How hard
>>>>> is it really to deal with assignment? Or does the issue have
>>>>> more to do with pointers, aliasing, etc.?
>>>> Actually aliasing is *the* hard issue.
>>> Okay, sure. Nice explanation.
>>>
>>> But one minor point: you describe this as an issue with "imperative"
>>> languages. But aliasing is a problem associated with pointers,
>>> not with assignment.
>> Aliasing is not a problem if the aliased data is immutable.
> 
> Okay, sure. But for the problem you describe, both imperativeness
> and the presence of pointers is each necessary but not sufficient;
> it is the two together that causes the problem. So it strikes
> me (again, a very minor point) as inaccurate to describe this as
> a problem with imperative languages per se.

Sure.
It's just that I know that it's viable to give up destructive updates. 
Giving up pointers is a far more massive restriction.

> Right. To me the response to this clear: give up pointers. Imperative
> operations are too useful to give up; indeed they are a requirement
> for certain problems.

I don't know any.
In some cases, you need an additional level of conceptual indirection - 
instead of *doing* the updates, you write a function that *describes* them.

 > Pointers on the other hand add nothing except
> efficiency and a lot of confusion. They should be considered an
> implementation technique only, hidden behind some pointerless
> computational model.
> 
> I recognize that this is likely to be a controversial opinion.

Indeed.

In fact "modes" are a way to restrict pointer aliasing.

> I heartily support immutability as the default, for these and other
> reasons.

OK, then we're in agreement here.

>> Some functional languages restrict assignment so that there can exist at
>> most a single reference to any mutable data structure. That way, there's
>> still no aliasing problems, but you can still update in place where it's
>> really, really necessary.
> 
> Are we speaking of uniqueness types now? I haven't read much about
> them, but it certainly seems like an intriguing concept.

Yup.
It's called "modes" in some other languages (Mercury or Clean IIRC).

>> I know of no professional language that doesn't have references of some
>> kind.
> 
> Ah, well. I suppose I could mention prolog or mercury, but then
> you used that troublesome word "professional." So I will instead
> mention a language which, if one goes by number of search results
> on hotjobs.com for "xxx progammer" for different value of xxx, is
> more popular than Java and twice as popular as C++. It lacks
> pointers (although I understand they are beginning to creep in
> in the latest version of the standard.) It also posesses a quite
> sophisticated set of facilities for declarative integrity constraints.
> Yet for some reason it is typically ignored by language designers.
> 
> http://hotjobs.yahoo.com/jobseeker/jobsearch/search_results.html?keywords_all=sql+programmer

Oh, right. SQL is an interesting case of getting all the problems of 
pointers without having them ;-)

Actually SQL has references - they are called "primary keys", but they 
are references nevertheless. (Some SQL dialects also offer synthetic 
"ID" fields that are guaranteed to remain stable over the lifetime of a 
record. Seems like SQL is imperative enough that programmers want this, 
else the SQL vendors wouldn't have added the feature...)
SQL also has updates.
The result: updates with undefined semantics. E.g. if you have a numeric 
key field, UPDATE commands that increment the key by 1 will fail or work 
depending on the (unspecified) order in which UPDATE touches the 
records. You can have even more fun with updatable views.
With a "repeatable read" isolation level, you actually return to a 
declarative view of the database: whatever you do with it, you won't see 
it until you commit the transaction. (As soon as you commit, the 
declarative peace is over and you better watch out that your data 
doesn't become inconsistent due to aliasing.)


Aliasing isn't really related to specific programming practices. If two 
accountants chat, and one talks about the hot blonde secretaire and the 
other about his adorable wife, you can imagine the awkwardness that 
ensues as soon as they find out they're talking about the same person!
The only thing that can really be done about it is not adding it 
artificially into a program. In those cases where aliasing is part of 
the modelled domain, you really have to carefully inspect all 
interactions and never, never, never dream about abstracting it away.


Regards,
Jo


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

Date: Thu, 13 Jul 2006 12:48:15 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e958mh$7sk$1@online.de>

Darren New schrieb:
> Joachim Durchholz wrote:
>> Actually, in a functional programming language (FPL), you write just 
>> the postconditions and let the compiler generate the code for you.
> 
> Certainly. And my point is that the postcondition describing "all valid 
> chess boards reachable from this one" is pretty much going to be as big 
> as an implementation for generating it, yes?

Yes. It's a classical case where the postcondition and the code that 
fulfils it are essentially the same.

 > The postcondition will
> still have to contain all the rules of chess in it, for example. At best 
> you've replaced loops with some sort of universal quanitifier with a 
> "such that" phrase.

Correct.

OTOH, isn't that the grail that many people have been searching for: 
programming by simply declaring the results that they want to see?

> Anyway, I expect you could prove you can't do this in the general case. 
> Otherwise, you could just write a postcondition that asserts the output 
> of your function is machine code that when run generates the same 
> outputs as the input string would. I.e., you'd have a compiler that can 
> write other compilers, generated automatically from a description of the 
> semantics of the input stream and the semantics of the machine the code 
> is to run on. I'm pretty sure we're not there yet, and I'm pretty sure 
> you start running into the limits of computability if you do that.

No, FPLs are actually just that: compilable postconditions.
Computability issues aren't more or less a factor than with other kinds 
of compilers: they do limit what you can do, but these limits are loose 
enough that you can do really useful stuff within them (in particular, 
express all algorithms).

Regards,
Jo


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

Date: Thu, 13 Jul 2006 12:55:25 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e9593v$8g3$1@online.de>

Marshall schrieb:
> David Hopwood wrote:
>> This property is, after all, not something that the program should depend on.
>> It is determined by how good the static checker currently is, and we want to be
>> able to improve checkers (and perhaps even allow them to regress slightly in
>> order to simplify them) without changing programs.
> 
> Hmmm. I have heard that argument before and I'm conflicted.

I'd want several things.

A way for me to indicate what assertions must be proven statically.
Highlighting (be it compiler messages or flashing colors in an IDE) that 
marks assertions that *will* break.
And highlighting for assertions that *may* break.
In the language, a (possibly) simplicistic inference engine definition 
that gives me minimum guarantees about the things that it will be able 
to prove; if something is out of the reach of the engine, a 
straightforward way to add intermediate assertions until the inference 
succeeds.

(Plus diagnostics that tell me where the actual error may be, whether 
it's a bug in the code or an omission in the assertions. That's probably 
the hardest part of it all.)

Regards,
Jo


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

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 V10 Issue 9461
***************************************


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