RE: Tie::Array::Sorted

2003-11-12 Thread Orton, Yves
Title: RE: Tie::Array::Sorted





 * Simon Cozens simon at simon-cozens.org [2003-11-12 13:32]:
  Is Tie::Array::Sorted a reasonable name for it, or would another one
  be more obvious?


DB_File has a way to do this iirc.


But it is a shocking ommission if there isnt at least one other way. I definately vote for Tie::Array::Sorted, but It may be worth having a look at Tie::Hash::Sorted and make them compatible on some level.


 This seems a reasonable name. Is there also a hash version in the
 works? I write:
 
 for my $key (sort keys %h) {
 ...
 
 often enough that I would use it.


Tie::Hash::Sorted (http://search.cpan.org/~jgatcomb/Tie-Hash-Sorted-0.10/Sorted.pm)
Tie::IxHash (http://search.cpan.org/author/GSAR/Tie-IxHash-1.21/lib/Tie/IxHash.pm)
Tie::Hash::Array (http://search.cpan.org/author/FANY/Tie-Hash-Array-0.01/lib/Tie/Hash/Array.pm)
Tie::SortHash (http://search.cpan.org/author/CTWETEN/Tie-SortHash-1.01/SortHash.pm)


:-)


Yves





Re: [Module::Build] Re: How to indicate a dependency in my module

2003-11-12 Thread Christopher Hicks
On Wed, 12 Nov 2003, Sam Vilain wrote:
 On Tue, 11 Nov 2003 02:29, Michael G Schwern wrote;
 
YAML was chosen because its human readable and writable, its data
 ^  ^
 So long as you're a FREAK who likes INDENTING and WHITESPACE to
 signify STRUCTURE.
 
 Is it any surprise that YAML is supported by PYTHON?!
 
 /topicalButTechnicallyVoidRantIgnoringTheObviousReplyForComicalValue

Considering the number of ugly languages that have been spawned from or
inspired by Perl, YAML may turn out to be one of the most respectable in
the long run.  At least it's not procedural like the other ugly children -
PHP and Python.

-- 
/chris

X Windows is to memory as Ronald Reagan was to money.
   -- Unix-Haters Handbook



Re: Tie::Array::Sorted

2003-11-12 Thread Randy W. Sims
Simon Cozens wrote:
Hi. I'm about to write a module which presents an array in sorted order;
$a[0] will always be the least element by some comparator. Miraculously,
there doesn't seem to be such a beast on CPAN already.
Is Tie::Array::Sorted a reasonable name for it, or would another one be more
obvious?
Sounds like a set/multiset/bag structure.

http://search.cpan.org/search?query=Setmode=all

Regards,
Randy.



Re: How to indicate a dependency in my module

2003-11-12 Thread A. Pagaltzis
* Bruno Negrao [EMAIL PROTECTED] [2003-11-10 20:11]:
 Im finishing to write a module, Proc::Daemontools, and it
 requires that the daemontools package be installed on a machine
 for it to work.  Where must I indicate that this module have a
 dependency?

I can't believe noone understood what you were talking about and
went off to lala-land. :-/

 In my test script, I cause the test to fail if it cannot find a
 process, 'svscan', running on the machine. Do you think that
 this can cause all the cpan-testers to fail?

Not a good approach for the reason you noted.

You seem to forget that Makefile.PL is a Perl script. :) I'd say
check for existence at the top of Makefile.PL and exit without
writing a Makefile and a status != 0 if you don't find it.

Make sure to provide a way for the user to supply a custom
location and inform them about it if your auto-find fails.
Something like

warn EOT
Can't find a daemontools installation on this system.
This module is useless without that package. If you don't
have it, see http://foo/bar/.

If you have them installed in a nonstandard location, set the
HAVE_DAEMONTOOLS environment variable to the correct
directory and rerun this script, as in

HAVE_DAEMONTOOLS=/opt/daemontools/ perl Makefile.PL

EOT

If $ENV{HAVE_DAEMONTOOLS} is set, I'd skip the check on the
premise that the user knows what they're doing. It might be worth
thinking about whether you want to autoedit your Perl sources in
that case too. Someone who passed a wrong location will just have
their tests fail. Alternatively you could skip the check only if
$ENV{FORCE} is set or some such.

-- 
Regards,
Aristotle
 
If you can't laugh at yourself, you don't take life seriously enough.


Re: Tie::Array::Sorted

2003-11-12 Thread Bruno Negrao
RE: Tie::Array::SortedHi Simon and others,

I agree that Tie::Array::Sorted is a good name.

But it is a shocking ommission if there isnt at least one other way. I
definately vote for
 Tie::Array::Sorted, but It may be worth having a look at Tie::Hash::Sorted
and make
 them compatible on some level.

And I agree that Tie::Array::Sorted should be compatible with Hash::Sorted
in some level. But I wouldn´t  like if Tie::Array  worked just like
Hash::Sorted because I don´t like it.

With Hash::Sorted we still have to know that enigmatic sorting subroutine:

 my $sort_by_numeric_value = sub {  #  this sub sucks!!
 my $hash = shift;
 [ sort {$hash-{$b} = $hash-{$a}} keys %$hash ];
 };

This is the difficult part that should be encapsulated, i think.

I suggest that you implement something like an ORDER attribute with the
values ASCENDING and DESCENDING, sparing us to know about that subroutine.

like this:

tie my @sorted_array, 'Tie::Array::Sorted',
 'Array' = \ @unsorted_array,
 'ORDER' = ASCENDING;

Also, you could try to guess (via regexps) if the data to be sorted is
numeric or alphabetical and use the appropriate subrouting to order it. But
if you don´t think this is a good idea, you could add another attribute
called TYPE with the values NUMERIC and ALPHABETICAL.

see ya,
bnegrao.




Re: Tie::Array::Sorted

2003-11-12 Thread A. Pagaltzis
* Bruno Negrao [EMAIL PROTECTED] [2003-11-12 18:47]:
 Also, you could try to guess (via regexps) if the data to be
 sorted is numeric or alphabetical and use the appropriate
 subrouting to order it.

Bleah. This kind of second-guessing easily leads to surprises.
Being explicit is good.

-- 
Regards,
Aristotle
 
If you can't laugh at yourself, you don't take life seriously enough.


Re: How to indicate a dependency in my module

2003-11-12 Thread Bruno Negrao
Hi Aristotle, (in portuguese your name is written Aristteles:)

 I can't believe noone understood what you were talking about and
 went off to lala-land. :-/
:-) hehehehe lala-land, that was fun!
Yes, they simply ignored what I asked them.

Even if I use the technique you suggested, when an automated cpan-tester
went to install my module, it will fail if it didnt have daemontools
installed, right?

I updated my test script avoiding it to fail if it cant find the
daemontools package installed. I would like to print a warning message to
the STDERR in order to advise about it, but I dont know how a cpan-tester
would react if it find some output to STDERR...

What do you know about it?

Thanks,
bnegrao



Re: How to indicate a dependency in my module

2003-11-12 Thread Randy W. Sims
Bruno Negrao wrote:

Hi Aristotle, (in portuguese your name is written Aristteles:)


I can't believe noone understood what you were talking about and
went off to lala-land. :-/
:-) hehehehe lala-land, that was fun!
Yes, they simply ignored what I asked them.
Even if I use the technique you suggested, when an automated cpan-tester
went to install my module, it will fail if it didnt have daemontools
installed, right?
I updated my test script avoiding it to fail if it cant find the
daemontools package installed. I would like to print a warning message to
the STDERR in order to advise about it, but I dont know how a cpan-tester
would react if it find some output to STDERR...
What do you know about it?

Thanks,
bnegrao

I was not ignoring your problem. Other than what had already been 
sugested there is currently no way to elegantly solve your problem which 
is why I wanted to discuss alternative mechanisms to solve this problem 
in the future. Hopefully you will soon be able to solve your problem by 
editing the META.yml file in your distribution. For now your only 
options are to skip or fail during 'make test' or to abort during 'perl 
Makefile.PL'. Most module authors choose the later.

Regards,
Randy.




Re: New modules

2003-11-12 Thread Ed Summers
On Wed, Nov 12, 2003 at 08:22:01PM +, Oliver White wrote:
 
 As a first step, I was considering adding a module to read GSHHS data [a 
 binary format for coastline data] and give it a name something like 
 Geo::GSHHS.  More info at the site:
 http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html

Sounds like a good idea to me, considering that Geo::ShapeFile is 
already established.

//Ed


Re: Tie::Array::Sorted

2003-11-12 Thread Tim Bunce
On Wed, Nov 12, 2003 at 09:42:05PM +, Nicholas Clark wrote:
 On Wed, Nov 12, 2003 at 10:16:51PM +0100, Paul Johnson wrote:
  On Wed, Nov 12, 2003 at 01:32:13PM +, Simon Cozens wrote:
  
   Hi. I'm about to write a module which presents an array in sorted order;
   $a[0] will always be the least element by some comparator. Miraculously,
   there doesn't seem to be such a beast on CPAN already.
   
   Is Tie::Array::Sorted a reasonable name for it, or would another one be more
   obvious?
 
  s/Tie::// ?
  
  Do I need to be concerned with how the module is implemented?
  Presumably the documentation will tell me how to use it.
  
  Yes, this probably applies to the rest of the Tie:: namespace too.
 
 Oh, I was going to say this.
 
 Tie::Array::Sorted is a good name because it is consistent with many
 other modules.
 
 But I consider them all to be misnamed. The implementation is not the
 most important feature of these modules - why is it the most important
 part of their names?

I disagree. The Tie:: doesn't just describe the implementation,
it describes the interface. And that's often a key aspect of
modules that offer functionality behind a tie interface.

Given a choice between Array::Sorted and Tie::Array::Sorted
I'd know that Tie::Array::Sorted provides a tie interface
and so will, for example, let me pass a ref to the array to code
I don't control and still get the behaviour I want.

Tim.


Re: New modules

2003-11-12 Thread James E Keenan
On Wed, 12 Nov 2003 20:22:01 +, Oliver White wrote:
 Hiya. I'm about to start work on some GIS programming in Perl, and
 will likely end up with a few modules that might usefully go onto
 CPAN.

 From what I've read on the FAQs though, it seems like a bit of a
 minefield to

 choose a name that someone else doesn't want,

See below.

 and to find out if
 anyone's already working in the same area.  I did some searches on
 the CPAN website for likely modules, while the documentation
 suggests I ask on some mailing lists, which I presume includes this
 one?

Yes, and possibly a post on comp.lang.perl.modules.  But this list is
where the issues will be argued back and forth.


 As a first step, I was considering adding a module to read GSHHS
 data [a binary format for coastline data] and give it a name
 something like Geo::GSHHS.  More info at the site:
 http://www.soest.hawaii.edu/wessel/gshhs/gshhs.html


To help us understand the problem better, could you spell out 'GSHHS'
and 'GIS'?

 Any comments?  Is this the right place to ask?

Yes, this is *definitely* the right place to ask.
 Is there already
 code somewhere that does it?  Would anyone be offended if I wrote
 the module?

No one will take offense if you write the module, but (as you imply
above) our fellow module-authors are picky about the names of new
modules.

One consideration here:  In the last week or so, there has been
discussion on this list re the general appropriateness of the 'Geo'
namespace.  It seems to be doing double-duty for both 'Geometry' and
'Geography' and some are advocating putting geographic modules in the
'Geography' namespace.  I'm not sure where that discussion ended up;
check the archives or Google it.  But you might want to wait for that
discussion to resolve before finalizing your own module's name.

Jim Keenan




Re: [Module::Build] Re: How to indicate a dependency in my module

2003-11-12 Thread Phil . Moore

OK, maybe I'm missing a LOT of context here, 'cause I haven't been
agressively keeping up with this mailing list, but the security hole
argument seems a bit odd.

These META.yml files we're refering to -- these are meta data for
managing the build process, files that will be distributed along with
the tarballs we upload to CPAN, right?  

So, if I understand this correctly, you're worried about the build
process eval'ing the contents of a file I sent you.  Hmm.

OK, why is that anymore of a concern for eval'ing the perl module I
also distributed, too?  Isn't that just as big a security hole?  

Or how about the test suites?  If I want to deploy malicious code in
my CPAN upload, I can just drop the evil code into my test suite, and
when you type make tes, I take over your world.

Am I missing something?  Because I also am loath to accept yet another
file format, personally, and I would also prefer to keep my
configuration data written in perl as well.

And if we're talking about the perl build process, what's wrong with a
perl-specific configuration mechanism?

 Michael == Michael G Schwern Michael writes:

Michael In a nutshell: eval()ing the Perl structure back in is a major security hole.
Michael Part of the point of META.yml is to avoid having to run any foreign code to
Michael figure out module meta information.

Michael To review (maybe this should be in a FAQ somewhere).

Michael Data::Dumper/Perl code - Insecure (you have to eval it).  Perl specific.
Michael Storable - Not human readable.  Format changes slightly from version to
Michael version.  Perl specific.
Michael XML  - Overkill.  Ugly.  Requires translation between Perl data
Michael model (hashes, lists, scalars) and XML's (trees).
Michael Difficult to read and write by humans.

Michael YAML was chosen because its human readable and writable, its data 
Michael structures closely match those of Perl (ie. scalars, hashes and arrays),
Michael it can be read without being eval'd, executable code cannot be hidden in
Michael it and, as a bonus, its not Perl specific.

Michael YAML's basic formatting is a structure we're already familiar with and tend
Michael to use when writing ad-hoc data structures (ie. key: value).
Michael Indentation as structure we're already more than comfortable with (ie. 
Michael indented source code) so readers of YAML should have no problem. 
Michael The less obvious features of YAML shouldn't be necessary for most META.yml
Michael files.

Michael Because YAML's data model closely matches that of Perl, writers of META.yml 
Michael simply need to construct a mirroring Perl structure and let YAML dump it
Michael out.  Its the closest thing to Data::Dumper evaling available.


Michael -- 
Michael Michael G Schwern[EMAIL PROTECTED]  http://www.pobox.com/~schwern/
Michael I'll tell you what beats voodoo every time, a big ass knife.
Michael -- Overkill Battlebot driver


Re: [Module::Build] Re: How to indicate a dependency in my module

2003-11-12 Thread Phil . Moore
 Chris == Christopher Hicks [EMAIL PROTECTED] writes:

 So, if I understand this correctly, you're worried about the build
 process eval'ing the contents of a file I sent you.  Hmm.
 
 OK, why is that anymore of a concern for eval'ing the perl module I
 also distributed, too?  Isn't that just as big a security hole?  

Chris There are any number of reasons I may be interested in
Chris examining your module for extracting documentation and
Chris dependancies without actually running a single line of your
Chris code.  The safer we make this sort of thing the more things
Chris like search.cpan.org and various more recent alternatives we'll
Chris have.

Ok, that makes sense... Thanks.  I hadn't really though about using
this data outside of the build process.


Re: [Module::Build] Re: How to indicate a dependency in my module

2003-11-12 Thread Nicholas Clark
On Wed, Nov 12, 2003 at 04:11:45PM +, Sam Vilain wrote:
 On Tue, 11 Nov 2003 02:29, Michael G Schwern wrote;
 
YAML was chosen because its human readable and writable, its data
 ^  ^
 So long as you're a FREAK who likes INDENTING and WHITESPACE to
 signify STRUCTURE.
 
 Is it any surprise that YAML is supported by PYTHON?!

no, not at ALL

but GIVEN that XS also treats INDENTING and WHITESPACE significantly,
it is STRANGE that there are no YAML modules for perl written in XS.

[although I believe that Ingy is working on something]

Nicholas Clark