[27956] in Perl-Users-Digest
Perl-Users Digest, Issue: 9320 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 20 06:10:15 2006
Date: Tue, 20 Jun 2006 03:10:06 -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 Tue, 20 Jun 2006 Volume: 10 Number: 9320
Today's topics:
Re: two servers listening on same port ? <sisyphus1@nomail.afraid.org>
Re: two servers listening on same port ? <siegel@zrz.tu-berlin.de>
Re: two servers listening on same port ? <sisyphus1@nomail.afraid.org>
Re: What is Expressiveness in a Computer Language <rNOSPAMon@flownet.com>
Re: What is Expressiveness in a Computer Language <vesa.karvonen@cs.helsinki.fi>
Re: What is Expressiveness in a Computer Language <robert.thorpe@antenova.com>
Re: What is Expressiveness in a Computer Language <rossberg@ps.uni-sb.de>
Re: What is Expressiveness in a Computer Language <pc@p-cos.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 Jun 2006 16:14:08 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: two servers listening on same port ?
Message-Id: <4497930e$0$20683$afc38c87@news.optusnet.com.au>
<sc_wizard29@hotmail.com> wrote in message
news:1150748276.735336.108720@p79g2000cwp.googlegroups.com...
> hi everyone,
>
> This ones makes me scratch my head : I'm using the following script on
> Windows and it looks like I can run two instances of it
> simultaneously...which means that I have 2 servers listening on the
> same port.
>
I have just been bitten by the same thing on Windows 2000 - during the
tidying up of some server and client scripts. I started getting inconsistent
behaviour that really had me puzzled (and irate) ... until I realised I had
four instances of the server script running concurrently - all listening to
the same port.
Not sure of the "approved" method for determining whether a port is in use.
As an interim measure I'm doing the following in an attempt to make sure I
don't make the same mistake again:
my $server_port = '2004'; # or whatever
my $netstat = `netstat -an`;
if($netstat =~ /:$server_port\s/) {die "Port already in use"}
# Followed by code to create the server listening on
# port $server_port
Cheers,
Rob
------------------------------
Date: Tue, 20 Jun 2006 10:58:27 +0200
From: Anno Siegel <siegel@zrz.tu-berlin.de>
Subject: Re: two servers listening on same port ?
Message-Id: <4fprosF1jtc7dU1@news.dfncis.de>
Sisyphus wrote:
>
> <sc_wizard29@hotmail.com> wrote in message
> news:1150748276.735336.108720@p79g2000cwp.googlegroups.com...
>> hi everyone,
>>
>> This ones makes me scratch my head : I'm using the following script on
>> Windows and it looks like I can run two instances of it
>> simultaneously...which means that I have 2 servers listening on the
>> same port.
[...]
> Not sure of the "approved" method for determining whether a port is in
> use.
As filehandles, sockets are flock-able. An exclusive lock in the
server should do:
flock $server, LOCK_EX | LOCK_NB or die "port in use";
(Untested, I can't open the port another time in the first place.)
Anno
------------------------------
Date: Tue, 20 Jun 2006 19:27:47 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: two servers listening on same port ?
Message-Id: <4497c06f$0$10288$afc38c87@news.optusnet.com.au>
"Anno Siegel" <siegel@zrz.tu-berlin.de> wrote in message
.
.
>
> > Not sure of the "approved" method for determining whether a port is in
> > use.
>
> As filehandles, sockets are flock-able. An exclusive lock in the
> server should do:
>
> flock $server, LOCK_EX | LOCK_NB or die "port in use";
>
Also not sure about the use of flock() on Win32. When I insert the above
code into my server script (which runs with warnings pragma enabled) it dies
with:
Argument "LOCK_OZ" isn't numeric in flock at file_server.plx line 35.
port in use at file_server.plx line 35.
Line 35 is simply the line that implements the above code - the port is
definitely not in use.
From 'perldoc -f flock' I find:
"Produces a fatal error if used on a machine that doesn't implement
flock(2), fcntl(2) locking, or lockf(3)."
'perldoc perlport' reports that fcntl() is not implemented on Win32, though
flock() *is* implemented ... not sure what to make of all that.
Sorry if I'm being dumb.
Cheers,
Rob
------------------------------
Date: Mon, 19 Jun 2006 21:30:11 -0700
From: Ron Garret <rNOSPAMon@flownet.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <rNOSPAMon-F06215.21301119062006@news.gha.chartermi.net>
In article <1150765102.867144.12590@h76g2000cwa.googlegroups.com>,
"Marshall" <marshall.spight@gmail.com> wrote:
> The conversation I would *really* like to have is the one where we
> discuss what all the differences are, functionally, between the two,
> and what the implications of those differences are, without trying
> to address which approach is "right" or "better", because those are
> dependent on the problem domain anyway, and because I can
> make up my own mind just fine about which one I prefer.
>
> The comp.lang.functional and comp.lang.lisp people are probably
> two of the smartest groups on usenet. (I do not consider myself
> a member of either group.) You wouldn't *think* that conversation
> would be *so* hard to have.
It's hard to have because there's very little to say, which leaves the
academics without enough to do to try to justify their existence. This
is the long and the short of it:
1. There are mismatches between the desired behavior of code and its
actual behavior. Such mismatches are generally referred to as "bugs" or
"errors" (and, occasionally, "features").
2. Some of those mismatches can be detected before the program runs.
Some can be detected while the program runs. And some cannot be
detected until after the program has finished running.
3. The various techniques for detecting those mismatches impose varying
degrees of burden upon the programmer and the user.
That's it. Everything else, including but not limited to quibbling over
the meaning of the word "type", is nothing but postmodernist claptrap.
IMHO of course.
rg
------------------------------
Date: 20 Jun 2006 05:05:14 GMT
From: Vesa Karvonen <vesa.karvonen@cs.helsinki.fi>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e77vma$ipe$1@oravannahka.helsinki.fi>
In comp.lang.functional Chris Smith <cdsmith@twu.net> wrote:
[...]
> Knowing that it'll cause a lot of strenuous objection, I'll nevertheless
> interject my plea not to abuse the word "type" with a phrase like
> "dynamically typed". If anyone considers "untyped" to be perjorative,
> as some people apparently do, then I'll note that another common term is
> "type-free," which is marketing-approved but doesn't carry the
> misleading connotations of "dynamically typed." We are quickly losing
> any rational meaning whatsoever to the word "type," and that's quite a
> shame.
[...]
FWIW, I agree and have argued similarly on many occasions (both on the
net (e.g. http://groups.google.fi/group/comp.programming/msg/ba3ccfde4734313a?hl=fi&)
and person-to-person). The widely used terminology (statically /
dynamically typed, weakly / strongly typed) is extremely confusing to
beginners and even to many with considerable practical experience.
-Vesa Karvonen
------------------------------
Date: 20 Jun 2006 02:12:25 -0700
From: "Rob Thorpe" <robert.thorpe@antenova.com>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <1150794745.148997.245840@b68g2000cwa.googlegroups.com>
Chris Smith wrote:
> Rob Thorpe <robert.thorpe@antenova.com> wrote:
> > A language is latently typed if a value has a property - called it's
> > type - attached to it, and given it's type it can only represent values
> > defined by a certain class.
>
> I'm assuming you mean "class" in the general sense, rather than in the
> sense of a specific construct of some subset of OO programming
> languages.
Yes.
> Now I define a class of values called "correct" values. I define these
> to be those values for which my program will produce acceptable results.
> Clearly there is a defined class of such values: (1) they are
> immediately defined by the program's specification for those lines of
> code that produce output; (2) if they are defined for the values that
> result from any expression, then they are defined for the values that
> are used by that expression; and (3) for any value for which correctness
> is not defined by (1) or (2), we may define its "correct" values as the
> class of all possible values.
I'm not talking about correctness, I'm talking about typing.
> Now, by your definition, any language
> which provides checking of that property of correctness for values is
> latently typed.
No, that isn't what I said. What I said was:
"A language is latently typed if a value has a property - called it's
type - attached to it, and given it's type it can only represent values
defined by a certain class."
I said nothing about the values producing correct outputs, or being
correct inputs. I only said that they have types.
What I mean is that each value in the language is defined by two peice
of information, its contents X and its type T.
> Of course, there are no languages that assign this
> specific class of values; but ANY kind of correctness checking on values
> that a language does (if it's useful at all) is a subset of the perfect
> correctness checking system above. Apparently, we should call all such
> systems "latent type systems".
No, I'm speaking about type checking not correctness.
> Can you point out a language that is not
> latently typed?
Easy, any statically typed language is not latently typed. Values have
no type associated with them, instead variables have types.
If I tell a C program to print out a string but give it a number it
will give an error telling me that the types mismatch where the
variable the number is held in is used to assign to a variable that
must hold a string. Similarly if I have a lisp function that prints
out a string it will also fail when given a number, but it will fail at
a different point, it will fail when the type of the value is examined
and found to be incorrect.
> I'm not trying to poke holes in your definition for fun. I am proposing
> that there is no fundamental distinction between the kinds of problems
> that are "type problems" and those that are not. Types are not a class
> of problems; they are a class of solutions.
Exactly. Which is why they are only tangentially associated with
correctness.
Typing is a set of rules put in place to aid correctness, but it is not
a system that attempts to create correctness itself.
> Languages that solve
> problems in ways that don't assign types to variables are not typed
> languages, even if those same problems may have been originally solved
> by type systems.
Well, you can think of things that way. But to the rest of the
computing world languages that don't assign types to variables but do
assign them to values are latently typed.
> > Untyped and type-free mean something else: they mean no type checking
> > is done.
>
> Hence, they don't exist, and the definitions being used here are rather
> pointless.
No they aren't, types of data exist even if there is no system in place
to check them. Ask an assembly programmer whether his programs have
string and integers in them and he will probably tell you that they do.
------------------------------
Date: Tue, 20 Jun 2006 11:29:58 +0200
From: Andreas Rossberg <rossberg@ps.uni-sb.de>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e78f6m$8usvs$1@hades.rz.uni-saarland.de>
Chris F Clark wrote:
>
> A static
> type system eliminates some set of tags on values by syntactic
> analysis of annotations (types) written with or as part of the program
> and detects some of the disallowed compuatations (staticly) at compile
> time.
Explicit annotations are not a necessary ingredient of a type system,
nor is "eliminating tags" very relevant to its function.
- Andreas
------------------------------
Date: Tue, 20 Jun 2006 12:01:34 +0200
From: Pascal Costanza <pc@p-cos.net>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <4fpvbvF1keed1U1@individual.net>
Marshall wrote:
> The conversation I would *really* like to have is the one where we
> discuss what all the differences are, functionally, between the two,
> and what the implications of those differences are, without trying
> to address which approach is "right" or "better", because those are
> dependent on the problem domain anyway, and because I can
> make up my own mind just fine about which one I prefer.
My current take on this is that static typing and dynamic typing are
incompatible, at least in their "extreme" variants.
The simplest examples I have found are this:
- In a statically typed language, you can have variables that contain
only first-class functions at runtime that are guaranteed to have a
specific return type. Other values are rejected, and the rejection
happens at compile time.
In dynamically typed languages, this is impossible because you can never
be sure about the types of return values - you cannot predict the
future. This can at best be approximated.
- In a dynamically typed language, you can run programs successfully
that are not acceptable by static type systems. Here is an example in
Common Lisp:
; A class "person" with no superclasses and with the only field "name":
(defclass person ()
(name))
; A test program:
(defun test ()
(let ((p (make-instance 'person)))
(eval (read))
(slot-value p 'address)))
(slot-value p 'address) is an attempt to access the field 'address in
the object p. In many languages, the notation for this is p.address.
Although the class definition for person doesn't mention the field
address, the call to (eval (read)) allows the user to change the
definition of the class person and update its existing instances.
Therefore at runtime, the call to (slot-value p 'adress) has a chance to
succeed.
(Even without the call to (eval (read)), in Common Lisp the call to
(slot-value p 'address) would raise an exception which gives the user a
chance to fix things and continue from the point in the control flow
where the exception was raised.)
I cannot imagine a static type system which has a chance to predict that
this program can successfully run without essentially accepting all
kinds of programs.
At least, development environments for languages like Smalltalk, Common
Lisp, Java, etc., make use of such program updates to improve
edit-compile-test cycles. However, it is also possible (and done in
practice) to use such program updates to minimize downtimes when adding
new features to deployed systems.
Pascal
--
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
------------------------------
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 9320
***************************************