Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The flaw of Java is that it is digsined for enforsing clean code for idiots

2 views
Skip to first unread message

atbu...@aol.com

unread,
May 16, 2006, 11:30:47 AM5/16/06
to
Bjarne Stroustrup has this to say:

"The connection between the language in which we think/program and
the
problems and solutions we can imagine is very close. For this
reason
restricting language features with the intent of eliminating
programmer errors is at best dangerous."

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

Lets take Perl for our example languige because it is a Hacker
Languige. That lets you shoot yourself in the foot. Perl lets you muck
in the symble table, Loop over objects acsess object members directly
and Gasp! change the inheratance tree on the fly

===================================================================

Larry Wall has this to say:

"The very fact that it's possible to write messy programs in Perl is
also what makes it possible to write programs that are cleaner in
Perl
than they could ever be in a language that attempts to enforce
cleanliness. The potential for greater good goes right along with
the
potential for greater evil."

===================================================================

Look at C and Pascal, C won because it _is_ a Hackers Languige.

Every good Languige has a Program[s] Built around, Java might be good
at embeded but not good for anything else. Perl was built for quick
scripts to munge files.

===================================================================

The definiton of an hackers languige is this, "It lets you shoot
yourself in the foot, because the power to do somthing stupid is the
power to solve problems that are near imposable in other languiges"

===================================================================

Paul graham has this to say.

>> 3. Give the Programmer as Much Control as Possible.

>> Many languages (especially the ones designed for other people) have the attitude of a
>> governess: they try to prevent you from doing things that they think aren't good for you. I
>> like the opposite approach: give the programmer as much control as you can.

atbu...@aol.com

unread,
May 16, 2006, 11:55:05 AM5/16/06
to
The definiton of an hackers languige is this, "It lets you shoot
yourself in the foot, because the power to do somthing stupid is the
power to do somthing clever"

Roedy Green

unread,
May 16, 2006, 2:53:37 PM5/16/06
to
On 16 May 2006 08:55:05 -0700, atbu...@aol.com wrote, quoted or
indirectly quoted someone who said :

>The definiton of an hackers languige is this, "It lets you shoot
>yourself in the foot, because the power to do somthing stupid is the
>power to do somthing clever"

The managerial way of looking at that is often "clever" ==
"unmaintainable" or "clever" == "impossible to port"

It is a matter of balancing short term vs long term pleasure.

Sometimes a clever thing can be buried and forever forgotten. It pays,
especially something in deep in the guts used all the time like the
call mechanism.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

atbu...@aol.com

unread,
May 16, 2006, 3:09:39 PM5/16/06
to
But somtimes being clever makes it cleaner because you dont have to
dance around the rules to make it compile

atbu...@aol.com

unread,
May 16, 2006, 3:13:27 PM5/16/06
to
Bjarne Stroustrup the creator of C++ the influance of java says that
restricting features for the sake of preventing programers from
shooting themselves in the foot is at the best dangerous!!!

atbu...@aol.com

unread,
May 16, 2006, 3:21:27 PM5/16/06
to
* Rule: "Don't Try To Force People"

Programmers are smart people. They are engaged in challenging
tasks and need all the help they can get from a programming language as
well as from other supporting tools and techniques. Trying to seriously
constrain programmers to do "only what is right" is inherently
wrongheaded and will fail. Programmers will find a way around rules and
restrictions they find unacceptable. The language should support a
range of reasonable design and programming styles rather than try to
force people into adopting a single notion.

This does not imply that all ways of programming are equally good
or that C++ should try to support every kind of programming style.
[...] However, moralizing over how to use the features is kept to a
minimum, language mechanisms are as far as possible kept policy free,
and no feature is added to or subtracted from C++ exclusively to
prevent a coherent style of programming.

I am well aware that not everyone appreciates choice and variety.
However, people who prefer a more restrictive environment can impose
one through style rules in C++ or choose a language designed to provide
the programmer with a smaller set of alternatives.

-- "The Design and Evolution of C++", page 113

Jeroen Wenting

unread,
May 16, 2006, 4:13:41 PM5/16/06
to

<atbu...@aol.com> wrote in message
news:1147806807.4...@j73g2000cwa.googlegroups.com...

> Bjarne Stroustrup the creator of C++ the influance of java says that
> restricting features for the sake of preventing programers from
> shooting themselves in the foot is at the best dangerous!!!
>
He would, he has after all a pension fund resting on the success of C++


Jeroen Wenting

unread,
May 16, 2006, 4:14:46 PM5/16/06
to

<atbu...@aol.com> wrote in message
news:1147806579.6...@y43g2000cwc.googlegroups.com...

> But somtimes being clever makes it cleaner because you dont have to
> dance around the rules to make it compile
>
No, if you need to do weird things to make something compile you have a
design flaw in your software.
That design flaw could be that you created it in the wrong language, but
more usually it's your understanding of that language and its facilities
that's at fault.


opalpa@gmail.com opalinski from opalpaweb

unread,
May 16, 2006, 4:15:06 PM5/16/06
to
Opalinski has this to say:

Java is great because it is easier to maintain other people's programs,
it is easier to comprehend and utilize other people's modules, and it
is easier to make manageable complex programs. Easier relative to C++,
Perl, and many others.

Getting a huge C++ or Perl program to enhance or debug is frequently an
excurtion to hell. Exceptional programmers (Stroustrup, Wall etc).
seem to be missing the fact that most programs written are by people
with no formal programming education and little experience. They
simultaneously seem to be missing the value of cooperating with all
these programmers.

All the best,
Opalinski
opa...@gmail.com
http://www.geocities.com/opalpaweb/

atbu...@aol.com

unread,
May 16, 2006, 4:42:09 PM5/16/06
to
Only if you work for Some BigCo.

atbu...@aol.com

unread,
May 16, 2006, 4:48:29 PM5/16/06
to
no non hacker languige lasted longer that 15 years

atbu...@aol.com

unread,
May 16, 2006, 4:52:28 PM5/16/06
to
Class::Struct reduces the nead for Boilerplate code AKA Crtl-c, Ctrl-z
coding

Casey Hawthorne

unread,
May 16, 2006, 8:40:22 PM5/16/06
to
atbu...@aol.com wrote:

>no non hacker language lasted longer that 15 years

LISP?
--
Regards,
Casey

asj

unread,
May 16, 2006, 11:14:09 PM5/16/06
to
atbu...@aol.com wrote:
> no non hacker languige lasted longer that 15 years

So, you're saying Java will be gone in 4 years? ROTFLOL.

Otis Bricker

unread,
May 16, 2006, 11:37:54 PM5/16/06
to
Casey Hawthorne <caseyhHA...@istar.ca> wrote in
news:p7pk62pgsa7hfjid1...@4ax.com:

COBOL?

OB

atbu...@aol.com

unread,
May 17, 2006, 11:44:07 AM5/17/06
to
No but it will be less populer in 4 years because of c# another B&D
languige. Lisp Is a hacker languige!!!!!!!!! perl is the opisite of a
B&D languige, thats why i use it!!!


B&D languiges do not alow you to solve complex problems esey and in the
hands of Code Jamers thats fine but to hackers all they care about is
POWER RAW POWER

COBOL is not that populer anymore

I ment populer

atbu...@aol.com

unread,
May 17, 2006, 11:55:51 AM5/17/06
to
The apidamy of B&D is ADA.

Otis Bricker

unread,
May 17, 2006, 1:02:38 PM5/17/06
to
atbu...@aol.com wrote in news:1147880647.807004.41280
@j73g2000cwa.googlegroups.com:

>
> COBOL is not that populer anymore
>
> I ment populer
>

But it was at one time and clearly lasted more that 15 years. Even Basic
has done that.

For the folks I know, the issue isn't raw power, it is productivity.
Sometimes that requires power. More often it requires other things like
cleanly expressed code concepts or good library availablity.

But I love you impression of Tim "The Tool Man" Taylor.

When do you hook that V8 to your riding mower?

OB

Roedy Green

unread,
May 17, 2006, 1:34:42 PM5/17/06
to
On 16 May 2006 12:13:27 -0700, atbu...@aol.com wrote, quoted or

indirectly quoted someone who said :

>Bjarne Stroustrup the creator of C++ the influance of java says that


>restricting features for the sake of preventing programers from
>shooting themselves in the foot is at the best dangerous!!!

Without explanation that is contradictory. It is like saying using a
net increases the danger of tight rope walking.

What he might mean is the safety net may cause people to become less
careful about checking and hence introduce more bugs overall. I have
not found that myself, though I did find it in Forth which has even
fewer safety nets. The reason is a program can ALMOST work in C++
with bugs but the odds of it almost working in FORTH are very low. It
either works or explodes spectacularly.

Lion-O

unread,
May 17, 2006, 8:29:19 PM5/17/06
to
> The definiton of an hackers languige is this, "It lets you shoot yourself in
> the foot, because the power to do somthing stupid is the power to solve
> problems that are near imposable in other languiges"

I've shot myself in the foot quite a couple of times with Java to be honost.
And guess what? I learned some very interesting things from it in the process.

So IMO that point is rather moot.

--
Groetjes, Peter

.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc

asj

unread,
May 18, 2006, 2:32:27 AM5/18/06
to
atbu...@aol.com wrote:
> No but it will be less populer in 4 years because of c# another B&D
> languige. Lisp Is a hacker languige!!!!!!!!! perl is the opisite of a
> B&D languige, thats why i use it!!!

You have no idea what you're talking about, do you?

Java, less popular? have you looked around you recently, or are you
buried so deeply in that spaghetti sauce called Perl that you missed
the last several years? C#? LOL.

http://www.google.com/trends?q=java%2Cc%23%2C+perl%2C+ruby%2Cpython&ctab=0&geo=all&date=all

Notice the 3 big red lines going downwards for Perl here:
http://www.tiobe.com/tpci.htm

yeah, I'm an idiot. I have two Masters degrees (MBA, Molec Bio) and own
a company. Yeah, sure I'm an idiot for using Java.

atbu...@aol.com

unread,
May 18, 2006, 4:04:07 PM5/18/06
to
You may not be one but, The avrage one is a stupid code jamer. a got a
pease of code in perls standard library that creates getters and
setters for you!
This code requires The abilaty to muck in the symble table at least.
Can Java Write Geters and Seters for you?

package Class::Struct;

## See POD after __END__

use 5.006_001;

use strict;
use warnings::register;
our(@ISA, @EXPORT, $VERSION);

use Carp;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(struct);

$VERSION = '0.63';

## Tested on 5.002 and 5.003 without class membership tests:
my $CHECK_CLASS_MEMBERSHIP = ($] >= 5.003_95);

my $print = 0;
sub printem {
if (@_) { $print = shift }
else { $print++ }
}

{
package Class::Struct::Tie_ISA;

sub TIEARRAY {
my $class = shift;
return bless [], $class;
}

sub STORE {
my ($self, $index, $value) = @_;
Class::Struct::_subclass_error();
}

sub FETCH {
my ($self, $index) = @_;
$self->[$index];
}

sub FETCHSIZE {
my $self = shift;
return scalar(@$self);
}

sub DESTROY { }
}

sub import {
my $self = shift;

if ( @_ == 0 ) {
$self->export_to_level( 1, $self, @EXPORT );
} elsif ( @_ == 1 ) {
# This is admittedly a little bit silly:
# do we ever export anything else than 'struct'...?
$self->export_to_level( 1, $self, @_ );
} else {
goto &struct;
}
}

sub struct {

# Determine parameter list structure, one of:
# struct( class => [ element-list ])
# struct( class => { element-list })
# struct( element-list )
# Latter form assumes current package name as struct name.

my ($class, @decls);
my $base_type = ref $_[1];
if ( $base_type eq 'HASH' ) {
$class = shift;
@decls = %{shift()};
_usage_error() if @_;
}
elsif ( $base_type eq 'ARRAY' ) {
$class = shift;
@decls = @{shift()};
_usage_error() if @_;
}
else {
$base_type = 'ARRAY';
$class = (caller())[0];
@decls = @_;
}

_usage_error() if @decls % 2 == 1;

# Ensure we are not, and will not be, a subclass.

my $isa = do {
no strict 'refs';
\@{$class . '::ISA'};
};
_subclass_error() if @$isa;
tie @$isa, 'Class::Struct::Tie_ISA';

# Create constructor.

croak "function 'new' already defined in package $class"
if do { no strict 'refs'; defined &{$class . "::new"} };

my @methods = ();
my %refs = ();
my %arrays = ();
my %hashes = ();
my %classes = ();
my $got_class = 0;
my $out = '';

$out = "{\n package $class;\n use Carp;\n sub new {\n";
$out .= " my (\$class, \%init) = \@_;\n";
$out .= " \$class = __PACKAGE__ unless \@_;\n";

my $cnt = 0;
my $idx = 0;
my( $cmt, $name, $type, $elem );

if( $base_type eq 'HASH' ){
$out .= " my(\$r) = {};\n";
$cmt = '';
}
elsif( $base_type eq 'ARRAY' ){
$out .= " my(\$r) = [];\n";
}
while( $idx < @decls ){
$name = $decls[$idx];
$type = $decls[$idx+1];
push( @methods, $name );
if( $base_type eq 'HASH' ){
$elem = "{'${class}::$name'}";
}
elsif( $base_type eq 'ARRAY' ){
$elem = "[$cnt]";
++$cnt;
$cmt = " # $name";
}
if( $type =~ /^\*(.)/ ){
$refs{$name}++;
$type = $1;
}
my $init = "defined(\$init{'$name'}) ? \$init{'$name'} :";
if( $type eq '@' ){
$out .= " croak 'Initializer for $name must be array
reference'\n";
$out .= " if defined(\$init{'$name'}) &&
ref(\$init{'$name'}) ne 'ARRAY';\n";
$out .= " \$r->$elem = $init [];$cmt\n";
$arrays{$name}++;
}
elsif( $type eq '%' ){
$out .= " croak 'Initializer for $name must be hash
reference'\n";
$out .= " if defined(\$init{'$name'}) &&
ref(\$init{'$name'}) ne 'HASH';\n";
$out .= " \$r->$elem = $init {};$cmt\n";
$hashes{$name}++;
}
elsif ( $type eq '$') {
$out .= " \$r->$elem = $init undef;$cmt\n";
}
elsif( $type =~ /^\w+(?:::\w+)*$/ ){
$out .= " if (defined(\$init{'$name'})) {\n";
$out .= " if (ref \$init{'$name'} eq 'HASH')\n";
$out .= " { \$r->$elem =
$type->new(\%{\$init{'$name'}}) } $cmt\n";
$out .= " elsif (UNIVERSAL::isa(\$init{'$name'},
'$type'))\n";
$out .= " { \$r->$elem = \$init{'$name'} }
$cmt\n";
$out .= " else { croak 'Initializer for $name must be
hash or $type reference' }\n";
$out .= " }\n";
$classes{$name} = $type;
$got_class = 1;
}
else{
croak "'$type' is not a valid struct element type";
}
$idx += 2;
}
$out .= " bless \$r, \$class;\n }\n";

# Create accessor methods.

my( $pre, $pst, $sel );
$cnt = 0;
foreach $name (@methods){
if ( do { no strict 'refs'; defined &{$class . "::$name"} } ) {
warnings::warnif("function '$name' already defined,
overrides struct accessor method");
}
else {
$pre = $pst = $cmt = $sel = '';
if( defined $refs{$name} ){
$pre = "\\(";
$pst = ")";
$cmt = " # returns ref";
}
$out .= " sub $name {$cmt\n my \$r = shift;\n";
if( $base_type eq 'ARRAY' ){
$elem = "[$cnt]";
++$cnt;
}
elsif( $base_type eq 'HASH' ){
$elem = "{'${class}::$name'}";
}
if( defined $arrays{$name} ){
$out .= " my \$i;\n";
$out .= " \@_ ? (\$i = shift) : return
\$r->$elem;\n";
$out .= " if (ref(\$i) eq 'ARRAY' && !\@_) {
\$r->$elem = \$i; return \$r }\n";
$sel = "->[\$i]";
}
elsif( defined $hashes{$name} ){
$out .= " my \$i;\n";
$out .= " \@_ ? (\$i = shift) : return
\$r->$elem;\n";
$out .= " if (ref(\$i) eq 'HASH' && !\@_) {
\$r->$elem = \$i; return \$r }\n";
$sel = "->{\$i}";
}
elsif( defined $classes{$name} ){
if ( $CHECK_CLASS_MEMBERSHIP ) {
$out .= " croak '$name argument is wrong class'
if \@_ && ! UNIVERSAL::isa(\$_[0], '$classes{$name}');\n";
}
}
$out .= " croak 'Too many args to $name' if \@_ > 1;\n";
$out .= " \@_ ? ($pre\$r->$elem$sel = shift$pst) :
$pre\$r->$elem$sel$pst;\n";
$out .= " }\n";
}
}
$out .= "}\n1;\n";

print $out if $print;
my $result = eval $out;
carp $@ if $@;
}

sub _usage_error {
confess "struct usage error";
}

sub _subclass_error {
croak 'struct class cannot be a subclass (@ISA not allowed)';
}

1; # for require


__END__

=head1 NAME

Class::Struct - declare struct-like datatypes as Perl classes

=head1 SYNOPSIS

use Class::Struct;
# declare struct, based on array:
struct( CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ... ]);
# declare struct, based on hash:
struct( CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });

package CLASS_NAME;
use Class::Struct;
# declare struct, based on array, implicit class name:
struct( ELEMENT_NAME => ELEMENT_TYPE, ... );

# Declare struct at compile time
use Class::Struct CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ...
];
use Class::Struct CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ...
};

# declare struct at compile time, based on array, implicit class
name:
package CLASS_NAME;
use Class::Struct ELEMENT_NAME => ELEMENT_TYPE, ... ;

package Myobj;
use Class::Struct;
# declare struct with four types of elements:
struct( s => '$', a => '@', h => '%', c => 'My_Other_Class' );

$obj = new Myobj; # constructor

# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s('new value'); # assign to element

# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a(2); # array element value
$obj->a(2, 'new value'); # assign to array element

# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h('x'); # hash element value
$obj->h('x', 'new value'); # assign to hash element

# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method(...); # call method of object
$obj->c(new My_Other_Class); # assign a new object

=head1 DESCRIPTION

C<Class::Struct> exports a single function, C<struct>.
Given a list of element names and types, and optionally
a class name, C<struct> creates a Perl 5 class that implements
a "struct-like" data structure.

The new class is given a constructor method, C<new>, for creating
struct objects.

Each element in the struct data has an accessor method, which is
used to assign to the element and to fetch its value. The
default accessor can be overridden by declaring a C<sub> of the
same name in the package. (See Example 2.)

Each element's type can be scalar, array, hash, or class.

=head2 The C<struct()> function

The C<struct> function has three forms of parameter-list.

struct( CLASS_NAME => [ ELEMENT_LIST ]);
struct( CLASS_NAME => { ELEMENT_LIST });
struct( ELEMENT_LIST );

The first and second forms explicitly identify the name of the
class being created. The third form assumes the current package
name as the class name.

An object of a class created by the first and third forms is
based on an array, whereas an object of a class created by the
second form is based on a hash. The array-based forms will be
somewhat faster and smaller; the hash-based forms are more
flexible.

The class created by C<struct> must not be a subclass of another
class other than C<UNIVERSAL>.

It can, however, be used as a superclass for other classes. To
facilitate
this, the generated constructor method uses a two-argument blessing.
Furthermore, if the class is hash-based, the key of each element is
prefixed with the class name (see I<Perl Cookbook>, Recipe 13.12).

A function named C<new> must not be explicitly defined in a class
created by C<struct>.

The I<ELEMENT_LIST> has the form

NAME => TYPE, ...

Each name-type pair declares one element of the struct. Each
element name will be defined as an accessor method unless a
method by that name is explicitly defined; in the latter case, a
warning is issued if the warning flag (B<-w>) is set.

=head2 Class Creation at Compile Time

C<Class::Struct> can create your class at compile time. The main
reason
for doing this is obvious, so your class acts like every other class in
Perl. Creating your class at compile time will make the order of
events
similar to using any other class ( or Perl module ).

There is no significant speed gain between compile time and run time
class creation, there is just a new, more standard order of events.

=head2 Element Types and Accessor Methods

The four element types -- scalar, array, hash, and class -- are
represented by strings -- C<'$'>, C<'@'>, C<'%'>, and a class name --
optionally preceded by a C<'*'>.

The accessor method provided by C<struct> for an element depends
on the declared type of the element.

=over 4

=item Scalar (C<'$'> or C<'*$'>)

The element is a scalar, and by default is initialized to C<undef>
(but see L<Initializing with new>).

The accessor's argument, if any, is assigned to the element.

If the element type is C<'$'>, the value of the element (after
assignment) is returned. If the element type is C<'*$'>, a reference
to the element is returned.

=item Array (C<'@'> or C<'*@'>)

The element is an array, initialized by default to C<()>.

With no argument, the accessor returns a reference to the
element's whole array (whether or not the element was
specified as C<'@'> or C<'*@'>).

With one or two arguments, the first argument is an index
specifying one element of the array; the second argument, if
present, is assigned to the array element. If the element type
is C<'@'>, the accessor returns the array element value. If the
element type is C<'*@'>, a reference to the array element is
returned.

As a special case, when the accessor is called with an array reference
as the sole argument, this causes an assignment of the whole array
element.
The object reference is returned.

=item Hash (C<'%'> or C<'*%'>)

The element is a hash, initialized by default to C<()>.

With no argument, the accessor returns a reference to the
element's whole hash (whether or not the element was
specified as C<'%'> or C<'*%'>).

With one or two arguments, the first argument is a key specifying
one element of the hash; the second argument, if present, is
assigned to the hash element. If the element type is C<'%'>, the
accessor returns the hash element value. If the element type is
C<'*%'>, a reference to the hash element is returned.

As a special case, when the accessor is called with a hash reference
as the sole argument, this causes an assignment of the whole hash
element.
The object reference is returned.

=item Class (C<'Class_Name'> or C<'*Class_Name'>)

The element's value must be a reference blessed to the named
class or to one of its subclasses. The element is not initialized
by default.

The accessor's argument, if any, is assigned to the element. The
accessor will C<croak> if this is not an appropriate object
reference.

If the element type does not start with a C<'*'>, the accessor
returns the element value (after assignment). If the element type
starts with a C<'*'>, a reference to the element itself is returned.

=back

=head2 Initializing with C<new>

C<struct> always creates a constructor called C<new>. That constructor
may take a list of initializers for the various elements of the new
struct.

Each initializer is a pair of values: I<element name>C< =E<gt>
>I<value>.
The initializer value for a scalar element is just a scalar value. The
initializer for an array element is an array reference. The initializer
for a hash is a hash reference.

The initializer for a class element is an object of the corresponding
class,
or of one of it's subclasses, or a reference to a hash containing named

arguments to be passed to the element's constructor.

See Example 3 below for an example of initialization.

=head1 EXAMPLES

=over 4

=item Example 1

Giving a struct element a class type that is also a struct is how
structs are nested. Here, C<Timeval> represents a time (seconds and
microseconds), and C<Rusage> has two elements, each of which is of
type C<Timeval>.

use Class::Struct;

struct( Rusage => {
ru_utime => 'Timeval', # user time used
ru_stime => 'Timeval', # system time used
});

struct( Timeval => [
tv_secs => '$', # seconds
tv_usecs => '$', # microseconds
]);

# create an object:
my $t = Rusage->new(ru_utime=>Timeval->new(),
ru_stime=>Timeval->new());

# $t->ru_utime and $t->ru_stime are objects of type Timeval.
# set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec.
$t->ru_utime->tv_secs(100);
$t->ru_utime->tv_usecs(0);
$t->ru_stime->tv_secs(5);
$t->ru_stime->tv_usecs(0);

=item Example 2

An accessor function can be redefined in order to provide
additional checking of values, etc. Here, we want the C<count>
element always to be nonnegative, so we redefine the C<count>
accessor accordingly.

package MyObj;
use Class::Struct;

# declare the struct
struct ( 'MyObj', { count => '$', stuff => '%' } );

# override the default accessor method for 'count'
sub count {
my $self = shift;
if ( @_ ) {
die 'count must be nonnegative' if $_[0] < 0;
$self->{'MyObj::count'} = shift;
warn "Too many args to count" if @_;
}
return $self->{'MyObj::count'};
}

package main;
$x = new MyObj;
print "\$x->count(5) = ", $x->count(5), "\n";
# prints '$x->count(5) = 5'

print "\$x->count = ", $x->count, "\n";
# prints '$x->count = 5'

print "\$x->count(-5) = ", $x->count(-5), "\n";
# dies due to negative argument!

=item Example 3

The constructor of a generated class can be passed a list
of I<element>=>I<value> pairs, with which to initialize the struct.
If no initializer is specified for a particular element, its default
initialization is performed instead. Initializers for non-existent
elements are silently ignored.

Note that the initializer for a nested class may be specified as
an object of that class, or as a reference to a hash of initializers
that are passed on to the nested struct's constructor.

use Class::Struct;

struct Breed =>
{
name => '$',
cross => '$',
};

struct Cat =>
[
name => '$',
kittens => '@',
markings => '%',
breed => 'Breed',
];


my $cat = Cat->new( name => 'Socks',
kittens => ['Monica', 'Kenneth'],
markings => { socks=>1, blaze=>"white" },
breed => Breed->new(name=>'short-hair',
cross=>1),
or: breed => {name=>'short-hair', cross=>1},
);

print "Once a cat called ", $cat->name, "\n";
print "(which was a ", $cat->breed->name, ")\n";
print "had two kittens: ", join(' and ', @{$cat->kittens}), "\n";

=back

=head1 Author and Modification History

Modified by Damian Conway, 2001-09-10, v0.62.

Modified implicit construction of nested objects.
Now will also take an object ref instead of requiring a hash ref.
Also default initializes nested object attributes to undef, rather
than calling object constructor without args
Original over-helpfulness was fraught with problems:
* the class's constructor might not be called 'new'
* the class might not have a hash-like-arguments constructor
* the class might not have a no-argument constructor
* "recursive" data structures didn't work well:
package Person;
struct { mother => 'Person', father => 'Person'};


Modified by Casey West, 2000-11-08, v0.59.

Added the ability for compile time class creation.

Modified by Damian Conway, 1999-03-05, v0.58.

Added handling of hash-like arg list to class ctor.

Changed to two-argument blessing in ctor to support
derivation from created classes.

Added classname prefixes to keys in hash-based classes
(refer to "Perl Cookbook", Recipe 13.12 for rationale).

Corrected behaviour of accessors for '*@' and '*%' struct
elements. Package now implements documented behaviour when
returning a reference to an entire hash or array element.
Previously these were returned as a reference to a reference
to the element.

Renamed to C<Class::Struct> and modified by Jim Miner, 1997-04-02.

members() function removed.
Documentation corrected and extended.
Use of struct() in a subclass prohibited.
User definition of accessor allowed.
Treatment of '*' in element types corrected.
Treatment of classes as element types corrected.
Class name to struct() made optional.
Diagnostic checks added.

Originally C<Class::Template> by Dean Roehrich.

# Template.pm --- struct/member template builder
# 12mar95
# Dean Roehrich
#
# changes/bugs fixed since 28nov94 version:
# - podified
# changes/bugs fixed since 21nov94 version:
# - Fixed examples.
# changes/bugs fixed since 02sep94 version:
# - Moved to Class::Template.
# changes/bugs fixed since 20feb94 version:
# - Updated to be a more proper module.
# - Added "use strict".
# - Bug in build_methods, was using @var when @$var needed.
# - Now using my() rather than local().
#
# Uses perl5 classes to create nested data types.
# This is offered as one implementation of Tom Christiansen's
"structs.pl"
# idea.

=cut

atbu...@aol.com

unread,
May 18, 2006, 4:14:25 PM5/18/06
to
Thats becaus of other factors like Python ,Ruby And PHP but thoes are
exsept PHP hackers languiges to so my argument stands Perl is still the
most powerfil scripting languige period! Peple Love Perl but does
ANYONE Love Java. C# is another D&B LANGUIGE THO NOT AS BAD AS Java but
bad Static Typeing && Strong Typeing && seprate boolean type == Evil.
Who kares whats popular all I kare about is Power do any of the other
scripting languiges have Anonumus functions, and automated Constructor
genoration. perl also alows you to know what is the colection type of
the variable wich is handy for removing ambiguity.

The Ghost In The Machine

unread,
May 18, 2006, 7:00:03 PM5/18/06
to
In comp.lang.java.advocacy, atbu...@aol.com
<atbu...@aol.com>
wrote
on 18 May 2006 13:04:07 -0700
<1147982647.1...@u72g2000cwu.googlegroups.com>:

> You may not be one but, The avrage one is a stupid code jamer. a got a
> pease of code in perls standard library that creates getters and
> setters for you!
> This code requires The abilaty to muck in the symble table at least.
> Can Java Write Geters and Seters for you?

A package named 'BCEL' can dynamically create classes, with certain
limitations.

http://jakarta.apache.org/bcel/

[PERL snipped]

--
#191, ewi...@earthlink.net
Windows Vista. Because it's time to refresh your hardware. Trust us.

asj

unread,
May 19, 2006, 12:59:54 AM5/19/06
to

atbu...@aol.com wrote:
> Thats becaus of other factors like Python ,Ruby And PHP but thoes are
> exsept PHP hackers languiges to so my argument stands Perl is still the
> most powerfil scripting languige period! Peple Love Perl but does
> ANYONE Love Java.

Dude, I LOVE Java, and I'll bet you a significant number of those
20,000 or so people at JavaOne do too.

I LOVE how I can code for my mobile phone at home, then code big java
for servers at work. I LOVE how I can muck around with smartcards, and
LEGO robots, and now even smart "mote" sensor networks using the same
language.

It's not how cleverly you code, it's what you do (and can do) with the
darn thing that matters.

ozgwei

unread,
May 19, 2006, 2:23:01 AM5/19/06
to

You can even spell correctly?
How can you claim you're clever?
How can you write programs other can understand and maintain it?
I wonder how many programmers have to clean up the mess you made...

Roedy Green

unread,
May 19, 2006, 7:01:54 PM5/19/06
to
On 18 May 2006 21:59:54 -0700, "asj" <kali...@yahoo.com> wrote,

quoted or indirectly quoted someone who said :

>Dude, I LOVE Java, and I'll bet you a significant number of those

You would enhance your credibility 10% by teaching your spell checker
to delete the word "dude". You claim degrees but sound like a 12 year
old when you use that equivalent to the older insolent term of address
"bub".

anon

unread,
May 21, 2006, 6:16:51 AM5/21/06
to
On Fri, 19 May 2006 23:01:54 GMT, Roedy Green
<my_email_is_post...@munged.invalid> wrote:

>On 18 May 2006 21:59:54 -0700, "asj" <kali...@yahoo.com> wrote,
>quoted or indirectly quoted someone who said :
>
>>Dude, I LOVE Java, and I'll bet you a significant number of those
>
>You would enhance your credibility 10% by teaching your spell checker
>to delete the word "dude". You claim degrees but sound like a 12 year
>old when you use that equivalent to the older insolent term of address
>"bub".

Spare me. If you had any understanding of human communication you
would understand that the connotation of the word, as used, involves
context. Without further insolent content it is obvious to all others
that it was a term intended to evoke inclusion, not derision. Nor was
it intended to slur your good family's name, your upbringing, or
anything else you seem to be in the mood to conjure.

You rejected the offer of inclusion because of some personal memories
associated with the word in question. Keep whatever they are to
yourself, will you, bub?

Many further examples available upon request.

Jim

Roedy Green

unread,
May 21, 2006, 4:18:33 PM5/21/06
to
On Sun, 21 May 2006 10:16:51 GMT, an...@anon.invalid.net (anon) wrote,

quoted or indirectly quoted someone who said :

>Spare me. If you had any understanding of human communication you


>would understand that the connotation of the word, as used, involves
>context

Check the context of this newsgroup. You will not see other people
addressing each other as "dude".

The point is when you persist in using a word, ANY WORD, after someone
tells you they find it offensive indicates you intend to offend. You
gain nothing from persisting other that pissing some people off.

It is your choice. Your choice has consequences, such as getting
plonked or hassled or ignored. I see you have chosen a very anonymous
non-descript handle. I take it you are anticipating being plonked from
the start since you know full well the consequences of your "fuck you"
posts.

anon

unread,
May 21, 2006, 11:59:11 PM5/21/06
to
On Sun, 21 May 2006 20:18:33 GMT, Roedy Green
<my_email_is_post...@munged.invalid> wrote:

>On Sun, 21 May 2006 10:16:51 GMT, an...@anon.invalid.net (anon) wrote,
>quoted or indirectly quoted someone who said :
>
>>Spare me. If you had any understanding of human communication you
>>would understand that the connotation of the word, as used, involves
>>context
>
>Check the context of this newsgroup. You will not see other people
>addressing each other as "dude".

You need to learn to use google. You want message counts? Is it used
every single day? Heavens, no. But I sure couldn't find anybody else
getting up on their high horse. Can you?

>The point is when you persist in using a word, ANY WORD, after someone
>tells you they find it offensive indicates you intend to offend. You
>gain nothing from persisting other that pissing some people off.

I'm not so sure. If I used a term that was intended to imply
inclusion, was not generally seen as a word that conveyed a negative
connotation and somebody teed off on me for the use of the word,
rather than deal with it politely, I might just goad that person on,
not to piss them off, per se (although that might certainly be one of
the consequences), but just to play with them. At some point, you
might hope that they come to their senses and realize that going off
the deep end was a bit on the silly side.

>It is your choice. Your choice has consequences, such as getting
>plonked or hassled or ignored. I see you have chosen a very anonymous
>non-descript handle. I take it you are anticipating being plonked from
>the start since you know full well the consequences of your "fuck you"
>posts.

If you think the prior post entered the fray at the "fuck you" level,
you have an amazing talent at hyperbole.

Take your hypersensivity and hyperbolic nature to a psychiatric haven
at first opportunity.

Jim

asj

unread,
May 22, 2006, 12:40:46 AM5/22/06
to
Roedy Green wrote:
> On 18 May 2006 21:59:54 -0700, "asj" <kali...@yahoo.com> wrote,
> quoted or indirectly quoted someone who said :
>
> >Dude, I LOVE Java, and I'll bet you a significant number of those
>
> You would enhance your credibility 10% by teaching your spell checker
> to delete the word "dude". You claim degrees but sound like a 12 year
> old when you use that equivalent to the older insolent term of address
> "bub".
> --

dude, you've just increased your chances of being called an old fuddy
daddy. i lived in california for a year or two, so sue me.

Tor Iver Wilhelmsen

unread,
May 22, 2006, 10:35:02 AM5/22/06
to
"asj" <kali...@yahoo.com> writes:

> dude, you've just increased your chances of being called an old fuddy
> daddy. i lived in california for a year or two, so sue me.

Aren't you, like, supposed to add, like, a ton of "like" in your,
like, sentences? Or is that just the Valley? Like?

The Ghost In The Machine

unread,
May 22, 2006, 11:00:05 AM5/22/06
to
In comp.lang.java.advocacy, Tor Iver Wilhelmsen
<jaded...@hotmail.com>
wrote
on 22 May 2006 16:35:02 +0200
<uveryj...@hotmail.com>:

San Fernando, maybe, but not Silicon. :-)

--
#191, ewi...@earthlink.net -- insert random English dialect here

Roedy Green

unread,
May 23, 2006, 2:43:22 PM5/23/06
to
On Mon, 22 May 2006 03:59:11 GMT, an...@anon.invalid.net (anon) wrote,

quoted or indirectly quoted someone who said :

>If you think the prior post entered the fray at the "fuck you" level,


>you have an amazing talent at hyperbole.

Once I ask you to stop addressing me that way, and you continue, THEN
it becomes a fuck you. It would not matter what the word was.

As I have said, it is your choice. The consequence is, if you persist
in addressing me as "dude" even in a group address, I will plonk you.
That means you won't get any help from me. I won't be contributing to
your threads, and as you are likely aware, posts attract posts so it
will to some extent cut down help and discussion from others too.

Also consider that if it bothers me enough to confront you, there are
probably others who don't like what you are doing but don't want to
make an issue over it. They will tend to give you a rougher time or
may even plonk you.

I am not particularly angry with you. I am trying to convince you that
your strategy of deliberately insulting people is self defeating.

I could start calling you "gay". To me that is not an insult. You
may consider it so. It would be childish of me to persist, insisting
that I see nothing wrong with it.

Further, it would be ridiculous. You are not gay and I am not a dude.

Also consider to folk raised the 50s that dude was the term of insult
used in all the westerns for an incompetent newcomer, particularly one
who elaborately dressed the part of a cowboy without any of the
skills(c.f. dude ranch) which are superposed on the later negative
connotations.

Roedy Green

unread,
May 23, 2006, 2:43:56 PM5/23/06
to
On 21 May 2006 21:40:46 -0700, "asj" <kali...@yahoo.com> wrote,

quoted or indirectly quoted someone who said :

>> old when you use that equivalent to the older insolent term of address


>> "bub".
>> --
>
>dude, you've just increased your chances of being called an old fuddy
>daddy. i lived in california for a year or two, so sue me.

Your choice. plonk.

opalpa@gmail.com opalinski from opalpaweb

unread,
May 24, 2006, 1:20:17 PM5/24/06
to
"Dude" has endearing connotation in my mind. It's a relaxed, hippy
form of "man". Sometimes I'm referrred to as dude and frankly I like
it.

I'm suprised to hear that it is considered insolant or offensive
elsewhere. Although not very suprised -- knowledge is a local
phenomena.

All the best,
Opalinski
opa...@gmail.com
http://www.geocities.com/opalpaweb/

IchBin

unread,
May 24, 2006, 4:35:01 PM5/24/06
to
Back in the 70's it had an endearing connotation of a relaxed, hippy
form of "man".

Now I think it is 'dog'?

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

anon

unread,
May 26, 2006, 1:13:50 PM5/26/06
to
On Tue, 23 May 2006 18:43:22 GMT, Roedy Green
<my_email_is_post...@munged.invalid> wrote:

>On Mon, 22 May 2006 03:59:11 GMT, an...@anon.invalid.net (anon) wrote,
>quoted or indirectly quoted someone who said :
>
>>If you think the prior post entered the fray at the "fuck you" level,
>>you have an amazing talent at hyperbole.
>
>Once I ask you to stop addressing me that way, and you continue, THEN
>it becomes a fuck you. It would not matter what the word was.

There is a huge difference between needling and a flame war.

>As I have said, it is your choice. The consequence is, if you persist
>in addressing me as "dude" even in a group address, I will plonk you.
>That means you won't get any help from me. I won't be contributing to
>your threads, and as you are likely aware, posts attract posts so it
>will to some extent cut down help and discussion from others too.

Plonking is the silliest form of usenet threat. There is always
another handle and another news feed to utilize. It is a threat
without substance of any kind. So, puhleaze spare me that sort of
hyperbolic nonsense.

Posts should be valued on their face, based on content. Anything else
is delusional.

>Also consider that if it bothers me enough to confront you, there are
>probably others who don't like what you are doing but don't want to
>make an issue over it. They will tend to give you a rougher time or
>may even plonk you.

Comical, actually.

>I am not particularly angry with you. I am trying to convince you that
>your strategy of deliberately insulting people is self defeating.

Needling doesn't rise to the level of truly insulting behaviour.
Again, the hyperbole.

>I could start calling you "gay". To me that is not an insult. You
>may consider it so. It would be childish of me to persist, insisting
>that I see nothing wrong with it.

I don't think the appropriate standard is what YOU think or what I
think. I think the appropriate standard is what the term or term is
generally meant. Otherwise it just becomes silly.

>Further, it would be ridiculous. You are not gay and I am not a dude.

You are correct about the former, but in California you might be one
of the coolest surfer dudes around. One never knows until one tries
the culture.

>Also consider to folk raised the 50s that dude was the term of insult
>used in all the westerns for an incompetent newcomer, particularly one
>who elaborately dressed the part of a cowboy without any of the
>skills(c.f. dude ranch) which are superposed on the later negative
>connotations.

Again, if it was meant that way, you have cause to gripe. If not, it
is merely silly, but borders on ridiculous when one persists.

But, in the spirit of a long weekend, I'm willing to let this
subthread die off.

Jim

0 new messages