Re: Bind Module for Perl
- From: Sergei Steshenko <sergstesh yahoo com>
- To: gtk-perl-list gnome org, jens luedicke gmail com
- Subject: Re: Bind Module for Perl
- Date: Fri, 31 Dec 2010 12:55:53 -0800 (PST)
--- On Fri, 12/31/10, Florian Ragwitz <rafl debian org> wrote:
From: Florian Ragwitz <rafl debian org>
Subject: Re: Bind Module for Perl
To: gtk-perl-list gnome org
Date: Friday, December 31, 2010, 7:17 AM
Jens Luedicke <jens luedicke gmail com>
writes:
I recently started to do some Perl hacking again and
missed a few
syntactic notations I knew from C++.
FWIW, those notations exist in C++ mostly because the
language doesn't
have proper closures, which Perl does have.
The syntax is basically the same. My approach is just
a little
different (maybe with a little more overhead). The
syntax offered by
Class::bind is probably more readable (which is very
important to me).
Readability is important. However, you might want to
consider that a
very fundamental feature of the Perl language is quite
likely to be
*much* more readable to Perl programmers than a module
reinventing that
feature so one can do the same thing with different
syntax.
[snip]
.
Exactly. C++ is a _very_ unreadable language; to prove this here is a
simple task to implement in C++ - translate the following _legal_ code
in Perl:
#------------------------------------------------------
my $some_coeff = 1.5;
my $hash_ref =
{
yet_another_hash =>
{
one => 1,
two => 2
},
array_of_hashes =>
[
{
name => 'John',
address => '1 Mary st'
},
{
name => 'Paul',
address => '5 James st'
}
],
a_method_with_two_closures =>
do{
my $another_coeff = 3.0;
sub # anonymous subroutine
{
my ($x) = @_;
$some_coeff * $another_coeff * $x; # the returned value
}
}
};
#------------------------------------------------------
into C++. You'll see how horrendously user unfriendly C++ (syntax) is.
I.e. you'll first of all see how difficult is to write all this in C++.
You'll see how much extra characters (what Perl bigots call "character
noise") you'll need to introduce into your C++ notation.
Perl is not "C" and actually was not meant to be, and it's good. Nor Perl
is C++, and one of fundamental differences is that in Perl constructor
_does_ return a value.
As my first exercise in C++ I tried to implement Perl hierarchical data
structures, and after that I realized how inconvenient C++ is.
Regards,
Sergei.
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]