[30571] in Perl-Users-Digest
Perl-Users Digest, Issue: 1814 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 22 21:09:51 2008
Date: Fri, 22 Aug 2008 18:09:14 -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 Fri, 22 Aug 2008 Volume: 11 Number: 1814
Today's topics:
A reference to a hash member? (to an object's member va <Alexander.Farber@gmail.com>
Re: A reference to a hash member? (to an object's membe sln@netherlands.com
Re: A reference to a hash member? (to an object's membe sln@netherlands.com
Re: A reference to a hash member? (to an object's membe <ben@morrow.me.uk>
Re: A reference to a hash member? (to an object's membe xhoster@gmail.com
Re: CLPM - a help group? <worrall.uunet@cs.bris.co.uk>
Re: CLPM - a help group? <worrall.uunet@cs.bris.co.uk>
Re: CLPM - a help group? <glennj@ncf.ca>
Re: CLPM - a help group? <jurgenex@hotmail.com>
idea: insertion operator jidanni@jidanni.org
Re: idea: insertion operator <ben@morrow.me.uk>
Re: Score files <worrall-unet@cs.bris.ca.uk>
Re: The Importance of Terminology's Quality sln@netherlands.com
Re: The Importance of Terminology's Quality sln@netherlands.com
Re: The Importance of Terminology's Quality <martin@see.sig.for.address.invalid>
Re: The Importance of Terminology's Quality sln@netherlands.com
Re: Unable to debug Perl script <szrRE@szromanMO.comVE>
Re: Unable to debug Perl script <nospam-abuse@ilyaz.org>
Re: Unable to debug Perl script <nospam-abuse@ilyaz.org>
Re: Unable to debug Perl script <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Aug 2008 14:15:24 -0700 (PDT)
From: "A. Farber" <Alexander.Farber@gmail.com>
Subject: A reference to a hash member? (to an object's member variable)
Message-Id: <624d93c1-6056-457a-9fbd-91c9d2b87d68@79g2000hsk.googlegroups.com>
Hello,
I have an object, which reads a header
from a non-blocking socket and if the header
indicates, that there is more data to read
(a chat string) then it will read that too.
To handle those 2 reading states
(reading a header; reading a chat string)
I try to use 3 variables: $buf, $toread, $offset
and then call sysread($buf, $toread, $offset).
My problem is, that I need to set
$buf to _point_ to $self->{REQ_HEADER}
in the 1st state and to $self->{CHAT}
in the 2nd state. But I don't know how.
In C-code (which I'm trying to port to Perl)
this has been very easy. But in Perl I don't
know how and rereading "perlref" doesn't help.
Any hints please?
Alex
PS: My complete, but buggy code is below:
sub read {
my $self = shift;
my $fh = $self->{FH};
my ($buf, $toread, $offset, $nbytes);
# start or continue reading the request header
if ($self->{NREAD} < REQ_HEADER_LEN) {
$buf = $self->{REQ_HEADER};
$offset = $self->{NREAD};
$toread = REQ_HEADER_LEN - $offset;
# start or continue reading the chat string
} else {
$buf = $self->{CHAT};
$offset = $self->{NREAD} - REQ_HEADER_LEN;
$toread = $self->{LEN} - $offset;
}
# XXX the buf is WRONG here:
$nbytes = $fh->sysread($buf, $toread, $offset);
unless (defined $nbytes) {
# interrupted by signal or would block - retry later
return if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK};
# connection interrupted - remove the Apache child
$self->remove($fh);
return;
}
if (0 == $nbytes) {
# connection closed - remove the Apache child
$self->remove($fh);
return;
}
$self->{NREAD} += $nbytes;
print STDERR "nbytes = $nbytes\n";
# not done yet - continue reading
return if $nbytes < $toread;
if (REQ_HEADER_LEN == $self->{NREAD}) {
($self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>{LEN}) =
unpack 'A32xN3', $self->{REQ_HEADER};
printf STDERR "sid=%s, event=%x, mod=%x, len=%x\n",
$self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>{LEN};
# not done yet - continue reading (the chat string)
return if $self->{LEN} > 0;
}
print STDERR "done reading";
#$Poll->mask($fh => POLLOUT);
}
------------------------------
Date: Fri, 22 Aug 2008 21:53:40 GMT
From: sln@netherlands.com
Subject: Re: A reference to a hash member? (to an object's member variable)
Message-Id: <6pcua4phld5ug1k55c8pg4rdqf90rolf6p@4ax.com>
On Fri, 22 Aug 2008 14:15:24 -0700 (PDT), "A. Farber" <Alexander.Farber@gmail.com> wrote:
>Hello,
>
>I have an object, which reads a header
>from a non-blocking socket and if the header
>indicates, that there is more data to read
>(a chat string) then it will read that too.
>
>To handle those 2 reading states
>(reading a header; reading a chat string)
>I try to use 3 variables: $buf, $toread, $offset
>and then call sysread($buf, $toread, $offset).
>
>My problem is, that I need to set
>$buf to _point_ to $self->{REQ_HEADER}
>in the 1st state and to $self->{CHAT}
>in the 2nd state. But I don't know how.
>
>In C-code (which I'm trying to port to Perl)
>this has been very easy. But in Perl I don't
>know how and rereading "perlref" doesn't help.
>
>Any hints please?
>Alex
>
>PS: My complete, but buggy code is below:
>
>sub read {
> my $self = shift;
> my $fh = $self->{FH};
> my ($buf, $toread, $offset, $nbytes);
>
> # start or continue reading the request header
> if ($self->{NREAD} < REQ_HEADER_LEN) {
> $buf = $self->{REQ_HEADER};
> $offset = $self->{NREAD};
> $toread = REQ_HEADER_LEN - $offset;
> # start or continue reading the chat string
> } else {
> $buf = $self->{CHAT};
> $offset = $self->{NREAD} - REQ_HEADER_LEN;
> $toread = $self->{LEN} - $offset;
> }
>
> # XXX the buf is WRONG here:
> $nbytes = $fh->sysread($buf, $toread, $offset);
>
> unless (defined $nbytes) {
> # interrupted by signal or would block - retry later
> return if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK};
> # connection interrupted - remove the Apache child
> $self->remove($fh);
> return;
> }
>
> if (0 == $nbytes) {
> # connection closed - remove the Apache child
> $self->remove($fh);
> return;
> }
>
> $self->{NREAD} += $nbytes;
> print STDERR "nbytes = $nbytes\n";
>
> # not done yet - continue reading
> return if $nbytes < $toread;
>
> if (REQ_HEADER_LEN == $self->{NREAD}) {
> ($self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>>{LEN}) =
> unpack 'A32xN3', $self->{REQ_HEADER};
>
> printf STDERR "sid=%s, event=%x, mod=%x, len=%x\n",
> $self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>>{LEN};
>
> # not done yet - continue reading (the chat string)
> return if $self->{LEN} > 0;
> }
>
> print STDERR "done reading";
> #$Poll->mask($fh => POLLOUT);
>}
I don't know for sure if "$fh->sysread() is valid (it may be),
but did you try this:
$nbytes = sysread($fh, $buf, $toread, $offset);
-------
sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
Also, OFFSET, in this case, is not the file offset. But I don't
know what your trying to achieve.
"An OFFSET may be specified to place the read data at some place in
the string other than the beginning. A negative OFFSET specifies
placement at that many characters counting backwards from the end
of the string. A positive OFFSET greater than the length of SCALAR
results in the string being padded to the required size with "\0"
bytes before the result of the read is appended"
sln
------------------------------
Date: Fri, 22 Aug 2008 22:06:09 GMT
From: sln@netherlands.com
Subject: Re: A reference to a hash member? (to an object's member variable)
Message-Id: <rkdua4ho4pslthh21esf0phc0322k1h2o0@4ax.com>
On Fri, 22 Aug 2008 21:53:40 GMT, sln@netherlands.com wrote:
>On Fri, 22 Aug 2008 14:15:24 -0700 (PDT), "A. Farber" <Alexander.Farber@gmail.com> wrote:
>
>>Hello,
>>
>>I have an object, which reads a header
>>from a non-blocking socket and if the header
>>indicates, that there is more data to read
>>(a chat string) then it will read that too.
>>
>>To handle those 2 reading states
>>(reading a header; reading a chat string)
>>I try to use 3 variables: $buf, $toread, $offset
>>and then call sysread($buf, $toread, $offset).
>>
>>My problem is, that I need to set
>>$buf to _point_ to $self->{REQ_HEADER}
>>in the 1st state and to $self->{CHAT}
>>in the 2nd state. But I don't know how.
>>
>>In C-code (which I'm trying to port to Perl)
>>this has been very easy. But in Perl I don't
>>know how and rereading "perlref" doesn't help.
>>
>>Any hints please?
>>Alex
>>
>>PS: My complete, but buggy code is below:
>>
>>sub read {
>> my $self = shift;
>> my $fh = $self->{FH};
>> my ($buf, $toread, $offset, $nbytes);
>>
>> # start or continue reading the request header
>> if ($self->{NREAD} < REQ_HEADER_LEN) {
>> $buf = $self->{REQ_HEADER};
>> $offset = $self->{NREAD};
>> $toread = REQ_HEADER_LEN - $offset;
>> # start or continue reading the chat string
>> } else {
>> $buf = $self->{CHAT};
>> $offset = $self->{NREAD} - REQ_HEADER_LEN;
>> $toread = $self->{LEN} - $offset;
>> }
>>
>> # XXX the buf is WRONG here:
>> $nbytes = $fh->sysread($buf, $toread, $offset);
>>
>> unless (defined $nbytes) {
>> # interrupted by signal or would block - retry later
>> return if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK};
>> # connection interrupted - remove the Apache child
>> $self->remove($fh);
>> return;
>> }
>>
>> if (0 == $nbytes) {
>> # connection closed - remove the Apache child
>> $self->remove($fh);
>> return;
>> }
>>
>> $self->{NREAD} += $nbytes;
>> print STDERR "nbytes = $nbytes\n";
>>
>> # not done yet - continue reading
>> return if $nbytes < $toread;
>>
>> if (REQ_HEADER_LEN == $self->{NREAD}) {
>> ($self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>>>{LEN}) =
>> unpack 'A32xN3', $self->{REQ_HEADER};
>>
>> printf STDERR "sid=%s, event=%x, mod=%x, len=%x\n",
>> $self->{SID}, $self->{EVENT}, $self->{MOD}, $self-
>>>{LEN};
>>
>> # not done yet - continue reading (the chat string)
>> return if $self->{LEN} > 0;
>> }
>>
>> print STDERR "done reading";
>> #$Poll->mask($fh => POLLOUT);
>>}
>
>I don't know for sure if "$fh->sysread() is valid (it may be),
>but did you try this:
>
>$nbytes = sysread($fh, $buf, $toread, $offset);
>
>-------
>
>sysread FILEHANDLE,SCALAR,LENGTH,OFFSET
>
>Also, OFFSET, in this case, is not the file offset. But I don't
>know what your trying to achieve.
>
>"An OFFSET may be specified to place the read data at some place in
>the string other than the beginning. A negative OFFSET specifies
>placement at that many characters counting backwards from the end
>of the string. A positive OFFSET greater than the length of SCALAR
>results in the string being padded to the required size with "\0"
>bytes before the result of the read is appended"
>
>
>sln
It is possible that "reads" need a reference to a buffer, I'm not
sure.
So, something like this would be necessary:
$buf = \$self->{REQ_HEADER};
unless $self->{REQ_HEADER} is already a SCALAR reference.
Not sure.
sln
------------------------------
Date: Fri, 22 Aug 2008 23:05:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: A reference to a hash member? (to an object's member variable)
Message-Id: <hpp3o5-kj7.ln1@osiris.mauzo.dyndns.org>
Quoth "A. Farber" <Alexander.Farber@gmail.com>:
> Hello,
>
> I have an object, which reads a header
> from a non-blocking socket and if the header
> indicates, that there is more data to read
> (a chat string) then it will read that too.
>
> To handle those 2 reading states
> (reading a header; reading a chat string)
> I try to use 3 variables: $buf, $toread, $offset
> and then call sysread($buf, $toread, $offset).
>
> My problem is, that I need to set
> $buf to _point_ to $self->{REQ_HEADER}
> in the 1st state and to $self->{CHAT}
> in the 2nd state. But I don't know how.
Use
$bufref = \$self->{REQ_HEADER};
to take a reference, and
sysread($$bufref, $toread, $offset);
to read into the variable referenced. Now go and reread perlref (again
:) ) and figure out why it works. Note that the first line parses as
$bufref = \( $self->{REQ_HEADER} );
and you could write it like that if you think it's clearer.
If you really object to the explicit ref syntax, you could use
Data::Alias:
use Data::Alias;
alias $buf = $self->{REQ_HEADER};
but you will need to learn to use references, in the long run.
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] ben@morrow.me.uk
------------------------------
Date: 22 Aug 2008 22:26:54 GMT
From: xhoster@gmail.com
Subject: Re: A reference to a hash member? (to an object's member variable)
Message-Id: <20080822182656.892$6l@newsreader.com>
"A. Farber" <Alexander.Farber@gmail.com> wrote:
>
> sub read {
> my $self = shift;
> my $fh = $self->{FH};
> my ($buf, $toread, $offset, $nbytes);
>
> # start or continue reading the request header
> if ($self->{NREAD} < REQ_HEADER_LEN) {
> $buf = $self->{REQ_HEADER};
Replace above line with $key ="REQ_HEADER";
> $offset = $self->{NREAD};
> $toread = REQ_HEADER_LEN - $offset;
> # start or continue reading the chat string
> } else {
> $buf = $self->{CHAT};
replace with $key = "CHAT";
> $offset = $self->{NREAD} - REQ_HEADER_LEN;
> $toread = $self->{LEN} - $offset;
> }
>
> # XXX the buf is WRONG here:
> $nbytes = $fh->sysread($buf, $toread, $offset);
replace with
$nbytes = $fh->sysread($self->{$key}, $toread, $offset);
(or use references)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 22 Aug 2008 11:32:32 -0700
From: Adam Worrall <worrall.uunet@cs.bris.co.uk>
Subject: Re: CLPM - a help group?
Message-Id: <sDDrk.18587$cW3.1490@nlpi064.nbdc.sbc.com>
Sherm Pendley wrote:
> Ben Morrow <ben@morrow.me.uk> writes:
>
>> Quoth Sherm Pendley <spamtrap@dot-app.org>:
>>> Adam Worrall <worrall-unet@cs.bris.ca.uk> writes:
>>>
>>> Nonsense. It's not a question of authority, it's one of accuracy. If I
>> Please stop responding to trolls. It's getting annoying.
>
> Actually, I don't think Adam began this as an intentional troll. He's
> obviously confused, but I think that's genuine, not trolling. Call it
> the triumph of hope over experience, if you will.
You people really are amazing. You think you can just pretend you are so
high above like this? That you think you know better, just like that?
When all you have been doing is repeated misquoting me and
misrepresenting what I said, over and over again, despite being
corrected, over and over?
> But you're right - Adam's argued himself into a corner at this point,
No, I've argued my way into pointlessness, as you just are so intend on
keeping your blinders on and keeping in line with the fantasy you've
created. Well done.
> and can't bring himself to admit that he's wrong,
I have no problem admitting I'm wrong when I genuinely am wrong, I
wasn't wrong here in reality, only in the way _you_ painted it, which
was royally inaccurate - you kept claiming I said something I _never_
once said, therefore you have absolutely no groups for claiming the win
here.
> no matter how many times it's explained to him.
Yet something can be explained to the likes of you 50 times over and you
are perfectly free to ignore it and pretend I said something I didn't,
and continue your points based on your own lie? Marvelous.
- Adam
------------------------------
Date: Fri, 22 Aug 2008 11:35:54 -0700
From: Adam Worrall <worrall.uunet@cs.bris.co.uk>
Subject: Re: CLPM - a help group?
Message-Id: <AGDrk.18588$cW3.18488@nlpi064.nbdc.sbc.com>
Jürgen Exner wrote:
> Adam Worrall <worrall-unet@cs.bris.ca.uk> wrote:
>> It's nothing short of bonified hypocrisy.
>
> *PLONK*
What's really sad here is that you people think typing "PLONK" makes you
some how special... as if the rest of the world is suppose to give a
rats ass... as if any genuine person actually buys into this sort of
bull shit.
- Adam
------------------------------
Date: 22 Aug 2008 18:40:43 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: CLPM - a help group?
Message-Id: <slrngau21a.btd.glennj@smeagol.ncf.ca>
At 2008-08-22 02:32PM, "Adam Worrall" wrote:
> Yet something can be explained to the likes of you 50 times over and you
[...]
Insanity: doing the same thing over and over again and expecting
different results.
-- Albert Einstein
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
------------------------------
Date: Fri, 22 Aug 2008 22:53:44 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: CLPM - a help group?
Message-Id: <angua4pv2hi49orbgghcpdbam7caovm1k0@4ax.com>
Adam Worrall <worrall.uunet@cs.bris.co.uk> wrote:
>Jürgen Exner wrote:
>> Adam Worrall <worrall-unet@cs.bris.ca.uk> wrote:
>>> It's nothing short of bonified hypocrisy.
>>
>> *PLONK*
>
>What's really sad here is that you people think typing "PLONK" makes you
>some how special... as if the rest of the world is suppose to give a
>rats ass... as if any genuine person actually buys into this sort of
>bull shit.
Oh, now you are worrall.uunet@cs.bris.co.uk. If you weren't ashamed of
your name you wouldn't have to change our ID.
Ifany other proof was needed, you just delivered it on a silver plater.
jue
------------------------------
Date: Sat, 23 Aug 2008 07:20:20 +0800
From: jidanni@jidanni.org
Subject: idea: insertion operator
Message-Id: <8763psvdqj.fsf@jidanni.org>
Gentlemen, ever wonder if there was an easier way to do
s/(bla)(goo)/$1NORD$2/
Well how about
s/bla^goo/NORD/
Yes, that's right, a new special operator (I'm overloading ^ here, but
I'm sure you can choose a wiser one that will also work at the beginng
of a line.) Anyway, this brilliant concept I hereby toss to you (and
run away). Anyway, probably not worth implementing as the $1 stuff is
more general.
------------------------------
Date: Sat, 23 Aug 2008 01:11:34 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: idea: insertion operator
Message-Id: <m614o5-0tb.ln1@osiris.mauzo.dyndns.org>
Quoth jidanni@jidanni.org:
> Gentlemen, ever wonder if there was an easier way to do
> s/(bla)(goo)/$1NORD$2/
> Well how about
> s/bla^goo/NORD/
> Yes, that's right, a new special operator (I'm overloading ^ here, but
> I'm sure you can choose a wiser one that will also work at the beginng
> of a line.) Anyway, this brilliant concept I hereby toss to you (and
> run away). Anyway, probably not worth implementing as the $1 stuff is
> more general.
Not quite as concise, but you can use
s/(?<=bla)(?=goo)/NORD/
provided 'bla' is a fixed-length string; or, with 5.10,
s/bla\K(?=goo)/NORD/
for any pair of patterns.
Ben
--
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent? [Feynmann] ben@morrow.me.uk
------------------------------
Date: Fri, 22 Aug 2008 11:24:03 -0700
From: Adam Worrall <worrall-unet@cs.bris.ca.uk>
Subject: Re: Score files
Message-Id: <uvDrk.18586$cW3.11882@nlpi064.nbdc.sbc.com>
Sherm Pendley wrote:
> Adam Worrall <worrall-unet@cs.bris.ca.uk> writes:
>
>> though. But this kill file business is just another indication of
>> going off the deep end - it's a personal utility, so please keep it
>> personal and talk about it over email, just as you've told others to
>> do for such things in the past.
>
> You don't know much about usenet, do you? First, you claim that it's a
> help desk, and now this...
Where do you get this? I _NEVER_ claimed it was a help desk. Not once.
Ever. I only ever said it _functioned_ like a certain type of one. I've
told you this over and over and so I have to now assume you are
purposely being dishonest by saying I said something I never said. Some
would consider this to be a form of lying.
> The meta-topic of NNTP client apps has traditionally been considered
> on-topic in all usenet groups, since everyone here is using such a
> client. The same is true of discussions about netiquette.
Yeah, it sure is easy to confuse a discussion about NNTP clients and one
about some egomaniac's kill file....
> With all due respect, I suggest that you put more time into learning
> what usenet *is*, before trying to change it into something else.
I know precisely what Usenet [sic] is and how it works and that you are
no authority. I also know exactly who and what you are: a lying sack of
shit who covers for his friends using any means necessary, even if it
means being utterly dishonest and deceptive.
- Adam
------------------------------
Date: Fri, 22 Aug 2008 22:56:09 GMT
From: sln@netherlands.com
Subject: Re: The Importance of Terminology's Quality
Message-Id: <l9gua4hv68o25l4ks0jsird8ou7gesflvl@4ax.com>
On Thu, 21 Aug 2008 09:11:48 -0500, rpw3@rpw3.org (Rob Warnock) wrote:
>sln@netherlands.com> wrote:
>+---------------
>| rpw3@rpw3.org (Rob Warnock) wrote:
>| >In the LGP-30, they used hex addresses, sort of[1], but the opcodes
>| >(all 16 of them) had single-letter mnemonics chosen so that the
>| >low 4 bits of the character codes *were* the correct nibble for
>| >the opcode! ;-}
>...
>| >[1] The LGP-30 character code was defined before the industry had
>| > yet standardized on a common "hex" character set, so instead of
>| > "0123456789abcdef" they used "0123456789fgjkqw". [The "fgjkqw"
>| > were some random characters on the Flexowriter keyboard whose low
>| > 4 bits just happened to be what we now call 0xa-0xf]. Even worse,
>| > the sector addresses of instructions were *not* right-justified
>| > in the machine word (off by one bit), plus because of the shift-
>| > register nature of the accumulator you lost the low bit of each
>| > machine word when you typed in instructions (or read them from
>| > tape), so the address values you used in coding went up by *4*!
>| > That is, machine locations were counted [*and* coded, in both
>| > absolute machine code & assembler] as "0", "4", "8", "j", "10",
>| > "14", "18", "1j" (pronounced "J-teen"!!), etc.
>|
>| Whats os interresting about all this hullabaloo is that nobody has
>| coded machine code here, and know's squat about it.
>+---------------
>
>Think again! *BOTH* of the two examples I gave -- for the LGP-30 & the
>IBM 1410 -- *WERE* raw machine code, *NOT* assembler!!! Please read again
>what I wrote about the character codes for the instruction mnemonics
>*BEING* the machine instruction codes. For the IBM 1410, the bootstrap
>code that ones types in:
>
> v v
> L%B000012$N
>
>*IS* raw machine code, *NOT* assembler!!
[snip]
I don't see the distinction.
Just dissasemble it and find out.
>
>you're typing *RAW* machine code, *NOT* assembler!! You see, the
>lower 4 bits of character "b" -- the "mnemonic" for "Bring" -- were
>binary 0001, the *same* as the lower 4 bits of the digit "1" (and two
>other characters as well). So when you typed a "b" in that position
>in "4-bit input mode" you were typing the same thing as the character "1"
>which was the same thing as *binary* 0001 which was the absolute machine
>opcode for the ""Bring" instruction!! "No assembler required" (pardon
>the pun).
>
>+---------------
>| I'm not talking assembly language.
>+---------------
>
>Neither was I. The fact that for the two machines I mentioned
>absolute machine code was somewhat readable to humans seems to
>have confused you, but that's the way some people liked to design
>their hardware back in those days -- with clever punning of character
>codes with absolute machine opcodes (for the convenience of the user).
>
>+---------------
>| Don't you know that there are routines that program machine code?
>+---------------
>
>What do you mean "routines"?!? For the above two machines, you can
>enter machine code with *no* programs ("routines?") running; that is,
>no boot ROM is required (or even available, as it happened).
>
[snip all the bullshit]
Each op is a routine in microcode.
That is machine code. Those op routines use machine cycles.
You hit the wall of understanding along time ago, a wall you
never looked past.
sln
------------------------------
Date: Fri, 22 Aug 2008 23:14:10 GMT
From: sln@netherlands.com
Subject: Re: The Importance of Terminology's Quality
Message-Id: <o7hua49gt4l4jfi2mv6lgg3njguc0476tj@4ax.com>
On Fri, 22 Aug 2008 11:11:09 -0400, George Neuner <gneuner2@comcast.net> wrote:
>On Thu, 21 Aug 2008 02:30:27 GMT, sln@netherlands.com wrote:
>
>>On Wed, 20 Aug 2008 21:18:22 -0500, rpw3@rpw3.org (Rob Warnock) wrote:
>>
>>>Martin Gregorie <martin@see.sig.for.address.invalid> wrote:
>>>+---------------
>>>| I was fascinated, though by the designs of early assemblers: I first
>>>| learnt Elliott assembler, which required the op codes to be typed on
>>>| octal but used symbolic labels and variable names. Meanwhile a colleague
>>>| had started on a KDF6 which was the opposite - op codes were mnemonics
>>>| but all addresses were absolute and entered in octal. I always wondered
>>>| about the rationale of the KDF6 assembler writers in tackling only the
>>>| easy part of the job.
>>>+---------------
>>>
>>>In the LGP-30, they used hex addresses, sort of[1], but the opcodes
>>>(all 16 of them) had single-letter mnemonics chosen so that the
>>>low 4 bits of the character codes *were* the correct nibble for
>>>the opcode! ;-}
>>>
>>>[Or you could type in the actual hex digits, since the low 4 bits
>>>of *their* character codes were also their corresponding binary
>>>nibble values... "but that would have been wrong".]
>>>
>>>
>>>-Rob
>>>
>>>[1] The LGP-30 character code was defined before the industry had
>>> yet standardized on a common "hex" character set, so instead of
>>> "0123456789abcdef" they used "0123456789fgjkqw". [The "fgjkqw"
>>> were some random characters on the Flexowriter keyboard whose low
>>> 4 bits just happened to be what we now call 0xa-0xf]. Even worse,
>>> the sector addresses of instructions were *not* right-justified
>>> in the machine word (off by one bit), plus because of the shift-
>>> register nature of the accumulator you lost the low bit of each
>>> machine word when you typed in instructions (or read them from
>>> tape), so the address values you used in coding went up by *4*!
>>> That is, machine locations were counted [*and* coded, in both
>>> absolute machine code & assembler] as "0", "4", "8", "j", "10",
>>> "14", "18", "1j" (pronounced "J-teen"!!), etc.
>>>
>>>-----
>>>Rob Warnock <rpw3@rpw3.org>
>>>627 26th Avenue <URL:http://rpw3.org/>
>>>San Mateo, CA 94403 (650)572-2607
>>
>>
>>Whats os interresting about all this hullabaloo is that nobody has
>>coded machine code here, and know's squat about it.
>
>A friend of mine had an early 8080 micros that was programmed through
>the front panel using knife switches ... toggle in the binary address,
>latch it, toggle in the binary data, latch it, repeat ad nauseam. It
>had no storage device initially ... to use it you had to input your
>program by hand every time you turned it on.
>
>I did a little bit of programming on it, but I tired of it quickly.
>As did my friend - once he got the tape storage working (a new prom)
>and got hold of a shareware assembler, we hardly ever touched the
>switch panel again. Then came CP/M and all the initial pain was
>forgotten (replaced by CP/M pain 8-).
>
>
>>I'm not talking assembly language. Don't you know that there are routines
>>that program machine code? Yes, burned in, bitwise encodings that enable
>>machine instructions? Nothing below that.
>>
>>There is nobody here, who ever visited/replied with any thought relavence that can
>>be brought foward to any degree, meaning anything, nobody....
>
>What are you looking for? An emulator you can play with?
>
>Machine coding is not relevant anymore - it's completely infeasible to
>input all but the smallest program. My friend had a BASIC interpreter
>for his 8080 - about 2KB which took hours to input by hand and heaven
>help you if you screwed up or the computer crashed.
>
>>sln
>
>George
I'm not looking for anything didn't you know?
I guess I wasn't talking assembly language, I was talking machine language.
The language behind the op codes, the one that takes cycles per 'op'eration.
It is entirely disgusting to listen to a littany of old time has beens who
did or did not work on old time cpu's that did or did not have an accumulator.
I worked with many cpu's at the assembly level, hell my first endevour was
writing dissasemblers, like Zilogs and pass through's to gain a whole different
instruction set.
I moved on, but before I did, I fully understood everyting I touched.
I've programmed over 14 million lines of code in my lifetime, but who gives
a rats ass.
Cpu's aren't complicated, far from it. Its having to eat the dubious constructs
of higher level languages built on those platforms.
Get your head out of the ground!
sln
------------------------------
Date: Fri, 22 Aug 2008 23:23:57 +0000 (UTC)
From: Martin Gregorie <martin@see.sig.for.address.invalid>
Subject: Re: The Importance of Terminology's Quality
Message-Id: <g8nhqd$6ri$2@localhost.localdomain>
On Fri, 22 Aug 2008 22:56:09 +0000, sln wrote:
> On Thu, 21 Aug 2008 09:11:48 -0500, rpw3@rpw3.org (Rob Warnock) wrote:
>
>>sln@netherlands.com> wrote:
>>*IS* raw machine code, *NOT* assembler!!
> [snip]
>
> I don't see the distinction.
> Just dissasemble it and find out.
>
There's a 1:1 relationship between machine code and assembler.
Unless its a macro-assembler, of course!
>
> Each op is a routine in microcode.
> That is machine code. Those op routines use machine cycles.
>
Not necessarily. An awful lot of CPU cycles were used before microcode
was introduced. Mainframes and minis designed before about 1970 didn't
use or need it and I'm pretty sure that there was no microcode in the
original 8/16 bit microprocessors either (6800, 6809, 6502, 8080, 8086,
Z80 and friends).
The number of clock cycles per instruction isn't a guide either. The only
processors I know that got close to 1 cycle/instruction were all RISC,
all used large lumps of microcode and were heavily pipelined.
By contrast the ICL 1900 series (3rd generation mainframe, no microcode,
no pipeline, 24 bit word) averaged 3 clock cycles per instruction.
Motorola 6800 and 6809 (no microcode or pipelines either, 1 byte fetch)
average 4 - 5 cycles/instruction.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
------------------------------
Date: Fri, 22 Aug 2008 23:36:07 GMT
From: sln@netherlands.com
Subject: Re: The Importance of Terminology's Quality
Message-Id: <q4jua4hchbccbn75scph8tkrjp7mu3423t@4ax.com>
On Fri, 22 Aug 2008 23:23:57 +0000 (UTC), Martin Gregorie <martin@see.sig.for.address.invalid> wrote:
>On Fri, 22 Aug 2008 22:56:09 +0000, sln wrote:
>
>> On Thu, 21 Aug 2008 09:11:48 -0500, rpw3@rpw3.org (Rob Warnock) wrote:
>>
>>>sln@netherlands.com> wrote:
>>>*IS* raw machine code, *NOT* assembler!!
>> [snip]
>>
>> I don't see the distinction.
>> Just dissasemble it and find out.
>>
>There's a 1:1 relationship between machine code and assembler.
>Unless its a macro-assembler, of course!
>
>>
>> Each op is a routine in microcode.
>> That is machine code. Those op routines use machine cycles.
>>
>Not necessarily. An awful lot of CPU cycles were used before microcode
>was introduced. Mainframes and minis designed before about 1970 didn't
>use or need it and I'm pretty sure that there was no microcode in the
>original 8/16 bit microprocessors either (6800, 6809, 6502, 8080, 8086,
>Z80 and friends).
>
>The number of clock cycles per instruction isn't a guide either. The only
>processors I know that got close to 1 cycle/instruction were all RISC,
>all used large lumps of microcode and were heavily pipelined.
>
>By contrast the ICL 1900 series (3rd generation mainframe, no microcode,
>no pipeline, 24 bit word) averaged 3 clock cycles per instruction.
>Motorola 6800 and 6809 (no microcode or pipelines either, 1 byte fetch)
>average 4 - 5 cycles/instruction.
Surely you have caved to intelligence. And there is nothing beyond op.
What has the friggin world come to!!!
sln
------------------------------
Date: Fri, 22 Aug 2008 11:11:23 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Unable to debug Perl script
Message-Id: <g8mvgf08pf@news4.newsguy.com>
Ben Morrow wrote:
> Quoth Peter Scott <Peter@PSDT.com>:
>> On Thu, 21 Aug 2008 11:15:00 -0400, smallpond wrote:
>> > FWIW, google finds a short method of generating this error.
>> >
>> > This is perl, v5.8.8 built for i386-linux-thread-multi
>> >
>> > perl -Te '@{%h}{x}'
>> > Bizarre copy of HASH in leave at -e line 1.
>>
>> Elegant. Looks fixed in 5.10. Either change 27350 or 25808.
>
> I should perhaps point out that this doesn't mean what you might
> think, and that in 5.10 its meaning has also been fixed.
>
> ~% perl5.8.8 -le'%h = qw/a b/; %{"1/8"} = qw/a c/; print @{%h}{a}'
> b
> ~% perl5.10.0 -le'%h = qw/a b/; %{"1/8"} = qw/a c/; print @{%h}{a}'
> c
>
> Perl used to allow you to treat a hash or array as a reference to
> itself; this was a bug, and has now been (partly) fixed. The way the
> expression now evaluates is
>
> Evaluate %h in scalar context -> '1/8'
> Evaluate @{'1/8'}{a} as a symbolic ref
>
> which is why the above gives 'c'. But since 5.8 and earlier
> incorrectly sliced %h rather than %{'1/8'}, you can't rely on this.
> (It would be stupid behaviour to rely on, in any case, since the
> exact value of a hash in scalar context has never been guaranteed.
> The only formal statement in the docs is that the value will be true
> iff the hash has any elements.)
>
> Under 'use strict' you get 'Can't use string ("1/8") as a HASH
> reference' with perls at least as far back as 5.6.1, so this won't be
> a problem in any normal code. If you want to slice %h, the correct
> syntax is simply
>
> @h{a}
Having read all this inspired me to run a few tests, and I found
something odd regarding allocation:
$ perl5.8.8 -Mstrict -we 'my %h; @h{1..1} = (1..100); print "[",
scalar %h, "]\n";'
[1/8]
$ perl5.8.8 -Mstrict -we 'my %h; @h{1..2} = (1..100); print "[",
scalar %h, "]\n";'
[2/8]
$ perl5.8.8 -Mstrict -we 'my %h; @h{1..3} = (1..100); print "[",
scalar %h, "]\n";'
[3/8]
$ perl5.8.8 -Mstrict -we 'my %h; @h{1..4} = (1..100); print "[",
scalar %h, "]\n";'
[3/8]
$ perl5.8.8 -Mstrict -we 'my %h; @h{1..5} = (1..100); print "[",
scalar %h, "]\n";'
[4/8]
I get the same using 5.10.0, 5.8.2, and 5.8.0. 5.6.1, however, shows
the fourth line as [4/8], and the 5th as [5/8], which is what I would
have exacted. It seems Perl 5.8.0 and above sometimes incorrectly return
the number of used buckets, as in the fourth line, there are four
key-value pairs, but only 3 buckets.... how can this be?
--
szr
------------------------------
Date: Fri, 22 Aug 2008 19:21:54 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Unable to debug Perl script
Message-Id: <g8n3ki$1mc$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
szr
<szrRE@szromanMO.comVE>], who wrote in article <g8mvgf08pf@news4.newsguy.com>:
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..4} = (1..100); print "[",
> scalar %h, "]\n";'
> [3/8]
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..5} = (1..100); print "[",
> scalar %h, "]\n";'
> [4/8]
>
>
> I get the same using 5.10.0, 5.8.2, and 5.8.0. 5.6.1, however, shows
> the fourth line as [4/8], and the 5th as [5/8],
So hashing algorithms in 5.6.1 is slightly better (on this particular
codeset). [No surprise for me; I suspect I know who optimized it. ;-]
With randomized hashing, 5 people with 8 possible birth-weekdays would
have a quite large chance of a collision, 1 - 8*7*6*5*4 / 5^8 = 80%
(birthday paradox). So it is not surprising that what you got is a
collision.
> which is what I would have exacted. It seems Perl 5.8.0 and above
> sometimes incorrectly return the number of used buckets, as in the
> fourth line, there are four key-value pairs, but only 3
> buckets.... how can this be?
Each bucket may keep an inlimited number of keys. [If you are lucky,
most buckets have only one key, and key lookup is quite quick.]
Hope this helps,
Ilya
------------------------------
Date: Fri, 22 Aug 2008 19:24:28 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Unable to debug Perl script
Message-Id: <g8n3pc$1n6$1@agate.berkeley.edu>
[A complimentary Cc of this posting was NOT [per weedlist] sent to
Ilya Zakharevich
<nospam-abuse@ilyaz.org>], who wrote in article <g8n3ki$1mc$1@agate.berkeley.edu>:
> With randomized hashing, 5 people with 8 possible birth-weekdays would
> have a quite large chance of a collision, 1 - 8*7*6*5*4 / 5^8 = 80%
^^^
8^5
> (birthday paradox). So it is not surprising that what you got is a
> collision.
[The answer is AFAIK correct, only the expresion was wrong...]
Sorry,
Ilya
------------------------------
Date: Fri, 22 Aug 2008 20:23:14 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Unable to debug Perl script
Message-Id: <2ag3o5-qd2.ln1@osiris.mauzo.dyndns.org>
Quoth "szr" <szrRE@szromanMO.comVE>:
>
> Having read all this inspired me to run a few tests, and I found
> something odd regarding allocation:
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..1} = (1..100); print "[",
> scalar %h, "]\n";'
> [1/8]
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..2} = (1..100); print "[",
> scalar %h, "]\n";'
> [2/8]
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..3} = (1..100); print "[",
> scalar %h, "]\n";'
> [3/8]
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..4} = (1..100); print "[",
> scalar %h, "]\n";'
> [3/8]
>
> $ perl5.8.8 -Mstrict -we 'my %h; @h{1..5} = (1..100); print "[",
> scalar %h, "]\n";'
> [4/8]
>
> I get the same using 5.10.0, 5.8.2, and 5.8.0. 5.6.1, however, shows
> the fourth line as [4/8], and the 5th as [5/8], which is what I would
> have exacted. It seems Perl 5.8.0 and above sometimes incorrectly return
> the number of used buckets, as in the fourth line, there are four
> key-value pairs, but only 3 buckets.... how can this be?
Learn how hash tables work. A 'bucket' isn't a key, but a set of keys
that hash to the same value; after that perl will do a linear scan
through all the keys in the bucket looking for one that matches.
Obviously, for efficiency, you want this final linear scan to be as
short as possible; this is why it is important to use a hash function
that distributes the keys evenly between the buckets.
Presumably the hash function was tweaked in 5.8, and two of the strings
'1'..'5' now end up in the same bucket; I would expect that this was
done to make some real-world set of keys distribute better, but I don't
know.
Ben
--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
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 1814
***************************************