Re: UI::Dialog Security Ideas

2013-08-20 Thread David Nicol
On Tue, Aug 20, 2013 at 11:39 AM, Kevin C. Krinke  wrote:

> Hi all,
>
> I've just noticed (yes, I've been way out of the loop on my own projects
> for far too long) the user reviews of my module UI::Dialog.
>
> In particular: http://cpanratings.perl.org/user/avian
> What really spoils the good impression is that it's full of security
> issues. Don't use for displaying any untrusted strings as it is trivial to
> trick the module into executing arbitrary shell commands.



I like using Tie::Function for providing interpolation-time sanitization
for data that is to get interpolated.

One could do something like this:

   use Tie::Function;
   tie our %SE, 'Tie::Function', sub {"\Q$_[0]\E"};  # Shell Escape

and then whenever the module does a system call, wrap the tainted variables.

That is, if you've currently got something like

  system("$command $arg1 $arg2");  # suboptimal, but works for this
example

that would become, assuming $command is coder-provided and the args are
from the user,

  system("$command $SE{$arg1} $SE{$arg2}");


This approach also works well for entity-encoding data that goes in hidden
field value elements in HTML forms, and preventing other types of code
injection.


Re: Alien::XXX needs something more

2013-08-09 Thread David Nicol
and for "windows" is meant Strawberry, Activestate,  Cygwin, or other?


Re: license information and link to source code repository from your CPAN distribution

2013-01-08 Thread David Nicol
On Tue, Jan 8, 2013 at 12:28 PM, John M. Gamble  wrote:

>
> It was not intended as a constantly synchronized central repository of all
> of CPAN.
>

That's what I meant, and it was something of a straw man.


Re: license information and link to source code repository from your CPAN distribution

2013-01-08 Thread David Nicol
On Tue, Jan 8, 2013 at 12:14 PM, Olaf Alders wrote:

> > uh, CPAN /is/ a public version control system. You have a favorite VCS
> and want to make diffs easily? Download, unpack, init, add, commit, work,
> diff.
>
> That doesn't sound easy at all.  ;)  For example, if you want to send a
> simple doc patch to an author who has the source code on Github, you can
> either jump through the hoops you're describing or
>
> a) fork the project on Github
> b) edit the file in place on Github
> c) click the pull request button
>
> That strikes *me* as much easier and you get built in request tracking.


actually, for a small patch without an explicit VCS framework, the
antediluvian workflow of unpacking twice, editing once, and using diff -U
to make the patch is a little simpler. Of  course you can't do that in a
web browser that I know of. At some point I switched to mercurial for such
one-offs, and as I'm still more comfortable with command line editing tools
than editing in place on Github, my workflow for editing something that's
on github still consists of checking it all out, editing it, then pushing
it back. I should look into editing in place with Github's web browser
editor.


Re: license information and link to source code repository from your CPAN distribution

2013-01-08 Thread David Nicol
> > Recently I checked and only 50% of the CPAN distributions have a link
> > to a public version control system:
> >
> http://blogs.perl.org/users/gabor_szabo/2013/01/50-of-the-new-cpan-uploads-lack-a-repository-link.html
>
> uh, CPAN /is/ a public version control system. You have a favorite VCS and
want to make diffs easily? Download, unpack, init, add, commit, work, diff.
I do admit I've started experimenting with adding github repos for my
modules, but I'm not at all certain that it is any improvement, and
demanding that as a requirement seems unnecessary.

On the other hand, a comprehensive "CPAN by git" as an additional CPAN
feature would have a measure of awesome to it, as an alternate distribution
and synchronization method.

The converse interpretation of the data -- fully half of new CPAN uploads
contain a link
to a non-CPAN VCS -- seems like a valid cause for celebration, rather than
alarmed finger-pointing at the non-adopters.

dln


Re: RFC: a universal tidier

2012-04-30 Thread David Nicol
On Sun, Apr 29, 2012 at 7:56 AM, Jonathan Swartz  wrote:
> Comments and suggestions for names welcome. Devel::MultiTidy?


I like the Any:: name space for things that offer single interfaces to
multiple back-ends. One could argue that Tidying really doesn't fit
there though. And that argument could be countered with hypothetical
examples involving large projects with different styles, enforced by
different tidying engines, for different parts of it, and the desire
for the scripts called at check-in time to run the correct tidying
engine by looking up per-file metadata.



-- 
In this document, the key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" are to be interpreted using situational ethics.


Re: Proposal for building module info

2012-02-10 Thread David Nicol
> At the moment I have everything internally under a CPAN::Curation::
> namespace, but if released separately I don't think that's appropriate.
>
> CPAN::Module::Metadata for the data class?
> CPAN::Module::GetMetadata for the builder? CPAN::Module::Metadata::Factory?
>

I like "Curation."  Museums are cool. Strengthening the "CPAN is Museum,
with even more stuff in the basement than what you see by strolling through
the galleries" idea may help with the endless stream of criticism from
people who want CPAN to be something other than what is is.

-- 
Digital artists often sneer when they effect an effect because sometimes
affect affects an effect's effect.


metacpan logo contest voting?

2012-01-30 Thread David Nicol
I like
http://entries.contest.metacpan.org/2012/01/andy-walker-3.html
the best but it isn't clear how to register this, aside from giving it a
Google plus point.



-- 
Digital artists often sneer when they effect an effect because sometimes
affect affects an effect's effect.


Re: The CPAN Morass

2011-12-02 Thread David Nicol
Bzzzt! Anachronism. I hereby retract my proposal to refund Linda W's fees.
Perl is, of course, four years older than Linux.

On Sat, Dec 3, 2011 at 12:21 AM, Linda W  wrote:

> What compiler on linux -- where perl was born, would you suggest?
>


Re: The CPAN Morass

2011-12-01 Thread David Nicol
I would like to nominate Linda W. for receipt of a full refund of her
CPAN subscription fees.


Re: The module authors pledge

2011-11-10 Thread David Nicol
> To make life easier for the perl modules cabal, how about a voluntary
>> pledge[*], which module authors can take publically, and in particular
>> can take to modu...@perl.org. I'll be emailing the following to
>> modu...@perl.org:
>>
>
No.
The license chaos is enough as it now is.


>
>>I hereby give modu...@perl.org permission to grant co-maintainership
>>to any of my modules, if the following conditions are met:
>>
>>(1) I haven't released the module for a year or more
>>
>
Complete modules don't get re-released, so this condition cannot be
sufficient on its own ... oh, that doesn't say "any of the..." does it.
Sorry.



>(2) There are outstanding issues on RT which need addressing
>>(3) Email to my CPAN email address hasn't been answered after a month
>>(4) The requester wants to make worthwhile changes that will benefit
>> CPAN
>>
>> So, what do y'all think?
>>
>
I think this is not necessary at all.  I think you have pretty much
described the current standards for granting takeover. I think the barrier
to making local forks is already very low and there is no reason to switch
the whole thing to Git.

I think CPAN is fine as it is.

-- 
"One only understands the things that one tames" -- the fox


Re: MetaCPAN is quickly becoming the de-facto interface to CPAN

2011-08-29 Thread David Nicol
On Sun, Aug 28, 2011 at 2:38 PM, Arthur Corliss
 wrote:
>   Google switching to SSL by default is as pointless as metacpan.  In
> the former case it's the "protection" of delivery to/from an entity that
> not only doesn't have your best interest at heart, but has a business built
> on exploiting *your* information for *its* benefit.  Utterly pointless.

I'll take this bait, swallow it, and hopefully bite off the line:

Yes, Google is going to use query data for its gain. But, Google's
business model
also involves *aggregation* and *respecting individual privacy*.

The SSL to Google Search is supposed to protect one from
eavesdropping, as has been
pointed out, by "the other people in Starbucks."  And it does this.

Say you're sitting in Starbucks, searching for clues concerning an embarrassing
medical condition. Your risk is, Mallory will intercept your packets
and tell his buddies
and they will huddle and point.

If some Google tech sees your query among the millions of other queries and
points it out to /his/ buddies and they huddle and point, that doesn't
affect you the same
way, if at all. They won't be pointing at you, the victim of an
embarrassing medical
condition, they will be merely pointing at an evidence of your
existence. And such
attention might actually bring more attention, in general, to the
problem of severe
triskaidekaphobia or whatever, which would be a good thing for you --
in the aggregate.
The resulting open discussion of severe triskaidekaphobia might help
lift the crippling stigma
that has followed the victims for so long, without any unpleasant
direct confrontations.


Re: Looking for people to take over maintenance of my Perl modules on CPAN

2011-08-02 Thread David Nicol
On Tue, Aug 2, 2011 at 11:03 AM, Terrence Brannon  wrote:
> I read the docs for your Logic::Kleene
> ( http://search.cpan.org/~rrwo/Logic-Kleene-0.05/lib/Logic/Kleene.pm ) and
> although I cant imagine a practical case where I would return undef as
> opposed to an explicit true or false, my instinct tells me that this module
> might be useful.

I'm not familiar with Kleene logic theory either, but i wonder if
wedging in some kind of deferral completion semantic would make sense.
Give a juggler enough coffee and he'll try to make everything both
non-blocking and synchronous.


Re: MetaCPAN is quickly becoming the de-facto interface to CPAN

2011-07-29 Thread David Nicol
On Fri, Jul 29, 2011 at 8:17 AM, David Golden wrote:
> I think MetaCPAN is a great project and is evolving quickly, but
> hyperbole doesn't serve any real benefit.


didn't someone here used to have "sure it's hyperbole, but you can
never have too much hyperbole" as their .sig?


Re: Handling C++ structs with XSpp

2011-04-26 Thread David Nicol
Have you considered using Inline::CPP and writing your accessors as
needed? Its another layer of indirection, but there may be fewer
surprises.


Re: CPAN In The Comics

2011-03-23 Thread David Nicol
we could finish the composition


Hey I code all day
Well I code all night
It's been six days
since I saw sunlight

I'm in troglodyte mode
Troglodyte mode

Got the Algol rhythm
Got the Assam blues
The lab is empty
I took off my shoes

The lights are out
sunglasses on
glowing pixels
syntax errors

.








On Wed, Mar 23, 2011 at 11:01 AM, John M. Gamble  wrote:

> Rhymes With Orange has a perlish flavor today:
>
> 
>
> For those of you with worse eyesight than mine, the modules listed are:
> Algorithm::Checkdigits
> SMS::Send
> HTTP::OAI
>
> Congratulations Mathias Weidner, Adam Kennedy, and Tim Brody.
>
>-john
>



-- 
simple interpolable credential obfuscator:
perl -ple 's/(.)/sprintf "\\%03o",ord $1/ge;'


Re: One possible future of parsing Graph::Easy input texts

2011-03-21 Thread David Nicol
On Mon, Mar 21, 2011 at 4:04 PM,  wrote:


> An interesting concept but describing the syntax as a grammar is not the
> same as an FSA. The FSA is part of the parser and lexer.
>

I disagree. "State Machine" is a powerful abstraction that is useful in many
places.


> The thing about parsing and Perl is that your lexer can be based on
> regular expressions which Perl of course understands itself. Regardless,
> the first step is to come up with a formal grammar. The RHS of the
> productions are calls to Graph::Easy.
>

Regular expressions describe state machines, for instance. Regex is a
descriptive (opposed to procedural) language. So is Graph::Easy.

At this time, we have a working parser for Graph::Easy regardless of how
> it was created. While a formal grammar is wonderful for documenting that
> language, why are we looking at replacing the parser in the first place?
> what size /complexity input is causing such a performance problem?
> Or is that new features for the language are desired and it is difficult
> to implement them in the existing system?
>

Yes, yes!  Perhaps Shlomi will explain exactly what the itch is that he's
scratching? I'm just guessing: does the existing Graph::Easy have issues
with mixed-direction unicode?


-- 
simple interpolable credential obfuscator:
perl -ple 's/(.)/sprintf "\\%03o",ord $1/ge;'


One possible future of parsing Graph::Easy input texts

2011-03-21 Thread David Nicol
On Sun, Mar 20, 2011 at 6:42 PM,  wrote:

> In terms of considering parser improvements or reimplementation, the first
> step is to come up with a formal grammar for the language.
> Preferably a Context Free Grammar (CFG) expressed in BNF or EBNF.
> Once we have that we have options
> - any of several Perl implementations including Parse::Yapp / Parse::Eyapp
> - using bison to generate a parser in C and then gluing that in with XS or
> even Inline::C




One could describe the Graph::Easy format grammar as a state machine, draw
the state machine with Graph::Easy, then implement a parser from your
diagram, with 
Graph::Easy::StateMachine
,
for a future Graph::Easy that is self-hosting. How cool would that be or
what?


-- 
"This is not a 'bug'. Being documented, it is merely a 'restriction'." --
Intercal manual


Re: Interesting licensing requires written permission of the author to modify it

2011-03-14 Thread David Nicol
On Mon, Mar 14, 2011 at 1:58 PM, Bill Ward  wrote:


> I think that copyright still applies for copying the original.  You don't
> have to make a derived work of an MP3 file for it to be an illegal copy for
> example.  But it does seem like posting it on CPAN would give de facto
> permission to copy the file.
>
> Also, just to be nice, you could write him for permission. He must be
>> awfully lonely, to use that for his license.
>>
>
> Poor fellow.
>

the difference -- and my source is having read a DJB essay on the subject --
is that you must legally obtain the work. Since its own CPAN, for download,
your copy is legally obtained. I have no use for the RIAA. Since they began
their reign of terror, I have destroyed all my recorded music. When I want
to hear something specific, I have my in-house minstrels.



-- 
"This is not a 'bug'. Being documented, it is merely a 'restriction'." --
Intercal manual


Re: Interesting licensing requires written permission of the author to modify it

2011-03-14 Thread David Nicol
On Mon, Mar 14, 2011 at 10:22 AM, Gabor Szabo  wrote:

> Hi I found a module on CPAN
> http://search.cpan.org/~goyali/google_talk_bot_v_01/
> with the following comment regarding licensing:
>
> "You are not allowed to modify the script unless having the written
> permission of abhishek jain"
>
> What do you think?
>
> Gabor
>

I think abishek jain's domain of control does not extend to you, and as long
as you aren't *distributing a derived work* copyright law does not apply. If
the script in question is a trade secret, he's done a really crappy job of
protecting it, posting it on CPAN and all.

Also, just to be nice, you could write him for permission. He must be
awfully lonely, to use that for his license.


-- 
"This is not a 'bug'. Being documented, it is merely a 'restriction'." --
Intercal manual


Re: best practices for module renaming

2011-02-08 Thread David Nicol
On Tue, Feb 8, 2011 at 6:29 AM, David Cantrell  wrote:
> On Mon, Feb 07, 2011 at 08:59:40PM +0100, Xavier Noria wrote:
>> Hi, I am the author of Net::FluidDB, which let's you talk to FluidDB.
>> FluidDB has been renamed to Fluidinfo, and I should rename the module
>> in accordance. Is there a recommended way to do this? Or should I just
>> upload a different distribution and document the rename?
>
> I'd upload a new distribution, rename the module, and also include a
> backward-compatibility wrapper module.

I would do nothing until there is a change in Fluidinfo that makes the
FluidDB module stop working. I would also continue to use the old name
"inappropriately" to annoy the marketeers.

And if the change really is name-only, I might upload a very light
Fluidinfo module that simply aliases the name space -- probably using
direct symbol table manipulation, instead of using the "Alias" module.


Re: Top level naming suggestion

2011-01-31 Thread David Nicol
> Before I upload the code (which is already written, for all methods MetaCPAN
> allows, and more) to CPAN and Github, I just wanted to know that taking a
> top-level namespace here makes sense and get any input on it. Here are some
> notes:
> 1. It does not use Mechanize, LWP, or anything for which the WWW:: namespace
> would make sense.

naming something after its implementation details doesn't make sense.
Including the name of a framework in the name of a plugin makes sense,
but that's different.

> 2. Tiny and concise, as to be an official completely workable API
> implementation (currently using Mouse - or rather, Any::Moose - and
> HTTP::Tiny).
> 3. I prefer not to bury this inside a low namespace
> (WebService::PerlRelated::MetaCPAN::API::Implementation::Sawyer).
> 4. I've spoken to Olaf Alders from MetaCPAN and he assured me they have no
> problem with the name, and that they would use it themselves once it's out.

how about MetaCPAN::API since that's what it provides? So
MetaCPAN::FAQ and MetaCPAN::Server can be at the same level. But
that's redundant isn't it; if one wants to "use MetaCPAN" one is going
to need to use the API -- including ::API may be toxic clarity.


Re: Discussion question: what is the best syntax for documenting a coderef parameter?

2010-12-09 Thread David Nicol
On Wed, Dec 8, 2010 at 7:59 PM, Eric Wilhelm  wrote:
>
> If you can, avoid the need to document "I will pass a callback to your
> callback".
>
> --Eric

Continuation-style programming requires that all the time.


Discussion question: what is the best syntax for documenting a coderef parameter?

2010-12-07 Thread David Nicol
The pod for AnyEvent::Handle contains < $cb->($handle, $host, $port, $retry->())
This callback is called when a connection has been successfully established.

The peer's numeric host and port (the socket peername) are passed as
parameters, together with a retry callback.
SNIP

Is C<$retry->()> the best way to represent that a coderef is required
there? It's clear, but I would have written it C<\&retry>. And I would
have written something confusing.

I think Marc Lehmann has done it the right way.


Re: What hurts you the most in Perl?

2010-12-06 Thread David Nicol
 We hear the same argument in reverse that people should work on Perl 5
 instead of Perl 6, as if the people who are working on Perl 6 would _of
 course_ be working on Perl 5 if 6 didn't exist. There's no reason to
 think  this is true, and many reasons to think it's not. Many Perl 6 people
 never contributed to Perl 5 the way they do with 6.
>>>
>>> Maybe there are others that said that, but I have said something related
>>> and I want to be more clear.
>>
>> I wasn't attributing this idea to you. The idea that Perl 6 has drained
>> development resources from Perl 5 has come up many times over the years.
>
>  For some reason this reminds me of the idea that's come up several times,
> that learning DBIC is quicker and easier than learning SQL if you don't know
> SQL already. Another idea I don't agree with, although I concede the idea
> that people would be working on Perl 6 if it weren't for Perl 5 focus is
> pure assumption based on no real evidence; much like the idea above.

As I recall, there was something of a glut of volunteers in 2000
gumming up the perl 5 maintenance works: one thing the perl 6 project
immediately succeeded at was, reduce the noise in p5p.

Also: ECMAscript is a standard, and is perfectly fine for what it is,
migrating systems other than client-side web page automations to it
continues to be wise.

Also: "going the way of FORTRAN or COBOL" looks, based on statistical
facts, to be a good thing -- an immense installed base of
mission-critical systems -- opposed to, say, going the way of Simula
or ALGOL, and being a fascinating historical footnote.

COBOL is the rivets in Big Iron.

-- 
"It is merely a matter of persistence." -- Albert Camus


Re: Reducing rsync cost (was: Re: Using a better compression than .gz for one's CPAN modules)

2010-11-22 Thread David Nicol
On Mon, Nov 22, 2010 at 4:37 AM, David Landgren  wrote:
> Yeah, this is the killer. In an ideal world, we would kill the symlinks such
> as authors/id/*, modules/by-category/*, modules/by-module/* and so on. These
> could be recreated via shell scripts locally on mirrors for people who wish
> to maintain these legacies. Cutting that out would diminish the rsync burden
> considerably.
>
> David

or re-engineer CPAN as a sqlite+FTSE database, and re-engineer the
mirroring process as a database mirror via a TBD compact database diff
protocol (I have no intention of doing any of this myself; good
morning)

-- 
"It is merely a matter of persistence." -- Albert Camus


Re: Please advise before I submit to CPAN

2010-09-09 Thread David Nicol
one surprising aspect of perl is that C affects the object, not
the reference, so it is possible to rebless things, which is handy if
you use package-based state machines

D:\>perl -le "bless $o=[],'abc';print $o; sub f{$l=shift; bless
$l,'DEF'} f $o; print $o"
abc=ARRAY(0x3e5444)
DEF=ARRAY(0x3e5444)

because after C< my $self = shift > you can bless $self and the
invocant will get reblessed.

So whenever anyone says "a Perl object is a blessed reference" they're
speaking procedurally, not descriptively. Descriptively, a Perl object
is a reference to a blessed thingy.

(I think that's correct terminology, please correct if wrong)


Re: Module name suggestions: A proper IO::Socket for IPv4/IPv6 duallity

2010-09-07 Thread David Nicol
Is IO::Socket::DWIM taken?


Re: Storable Stream - Module namespace help

2010-08-09 Thread David Nicol
On Sun, Aug 8, 2010 at 4:58 AM, Marco Neves [ModAuthors]
 wrote:
> Hello,
>
>        In need for a way to transfer a large amount of small datastructures I
> created a module that stores and retrieves a stream of storables in a file.

I'm confused -- a stream can't be stored in a file, because it is
continually generated.

Also, what is different about this freezer/thawer that makes it
superior to, for instance, YAML or compressed Data::Dumper dumps?

That is, for what general class of use cases would one prefer the
Neves data marshalling system to the available others?

Also, if you're reusing other things in it -- you say "storables" are
you doing something like prefixing length and colon to the output of
Storable and jamming a bunch of those together? -- the underlying
technology and then "stream" might make sense, especially if it can
take an open handle instead of a file name in its constructor. Such a
thing could be nice for creating an abstracted pipe between
distributed processes for instance.


Re: Frozen Bubble 2.2.1

2010-08-05 Thread David Nicol
It appears that your use case -- you want to publish the beta version
on CPAN without having the non-beta-testers get it too -- is not
supported by xdg's essay.

I see two possible approaches:

1: leapfrogging. Release the beta versions with version numbers that
are less than the latest release version. This approach might require
some planning, possibly including bumping the version number on the
current stable to make space. The beta testers will have to jump
through something of a hoop, depending on their tools and skill with
them, so you'll have to support them in that.

2: release beta versions in an entirely separate name-space, so
instead of having the beta after Awesome::Application 3.003 having
confusing version number just call it Awesome::Application_betatest
3.004 and let them coexist. Some research may be required to figure
out the best way to do that -- you don't want CPAN.pm pulling in the
Betatest version of something unreleased because it includes something
that it thinks is a proper upgrade, for instance. The additional
end-user control over what code is participating in the testing, for
a module, with less risk, could be good, too, for a module.


Re: Roles on the CPAN

2010-08-05 Thread David Nicol
package that;
use Moose;
with 'fries';

# do we want this?


Re: Opinions about constants

2010-07-29 Thread David Nicol
On Thu, Jul 29, 2010 at 3:28 PM, Bill Moseley  wrote:
> Wondering what you use for constants in your modules.

I actually do stuff like

BEGIN {
   my %SmallEnglishNumbers = qw/
  ONE => 1 TWO => 2 TWELVE => 12, INF => -1 , ZAPHOD => 42
   /;
  my $block;
  while (my ($k,$v) = each %SmallEnglishNumbers){
  $block .= "sub $k() { $v }\n";
  }
  eval "$block 1" or die "Whoops, botched block:\n$block\n with err:\n$@"
}

pretty regularly.

The thing Constant:: will give you that this approach doesn't is dualvars.


Re: Why are you releasing modules to CPAN?

2010-05-27 Thread David Nicol
On Thu, May 27, 2010 at 6:00 PM, Eric Wilhelm  wrote:

Because if you don't publish your work, you aren't doing science?  The
> proprietary model works by putting the smallest saleable innovation in
> an opaque box by itself and collecting rent.  If there were a viable
> model somewhere between that and "completely free", software would be
> much better off and we wouldn't need to be asked about all of these
> warm and fuzzy reasons for showing our work.
>

my contributions CPAN are there to give free samples of what I can do; they
function as an artisan's portfolio. Their existence gives some gravitas to
my professional statements on things perly. And, the occasional notice that
some have been reused is thrilling; especially bug reports and contributed
fixes.


famouswhy?

2010-05-13 Thread David Nicol
Is everyone getting notifications from famouswhy today concerning
things on CPAN, or did my "famous" module actually go though some kind
of nomination and confirmation process? I don't know if I should be
proud or annoyed.


Re: Usage of wantarray

2010-05-12 Thread David Nicol
On Wed, May 12, 2010 at 7:08 AM, Shlomi Fish  wrote:
> On Wednesday 12 May 2010 00:55:13 Lutz Gehlen wrote:
>> Hello everybody,
>> recently, I read the following statement in a CPAN Ratings entry:
>> "this package also uses wantarray (a transgression amongst interface
>> sensibilities)."

C is how to distinguish between array, scalar, and void contexts.

When you want to distinguish between numeric, string, scalar-ref,
array-ref, and hash-ref scalar contexts, C works for that.

The sensibilities allegedly transgressed may be peculiar to the author
of that comment.

-- 
"To avoid both financial loss and jail time, we provide security
mechanisms, including access control." -- Mike Burrows, 2006


Re: CPAN Meta Spec Version 2 released

2010-04-20 Thread David Nicol
On Mon, Apr 19, 2010 at 7:51 AM, David Golden  wrote:

> Dotted-decimals have a "round-trip" problem when being compared to
> decimals.  Depending on the order that things are converted, you can
> get different answers.
>
> Consider "v1.2.1000.3".  How should that be converted to a decimal
> version?

At the cost of both readability and backwards-compatibility,
prefixing each part with a length digit 0-9 where 0 means 1 and 9
means ten would give a round-trip capability for parts up to ten
digits long while preserving the ability to sort numerically after
converting to floating point. Add a final 5 always to prevent trailing
zeroes getting lost and annoy rounding algorithms.

v1.2.1000.3 would become 1.023135
v1.2.999.3   would become 1.022999035


-- 
I like to think that when I ramble on, I'm speaking for others who
share my opinions or point of view but who aren't as expressive.


Re: Applications on CPAN

2010-04-18 Thread David Nicol
Someone please correct me im I'm wrong.

Once upon a time, CPAN was supposed to hold applications as well as modules.
There were so many more modules than applications that indexing and so on
tools for modules entirely eclipsed applications.

With the result that if you want to share an application using CPAN, the
best way to do that is to express the application as a module and include an
invocation script in the documentation, something like

nohup perl -MLeoNerd::CircleIRC::app -e 'run' &



On Sun, Apr 18, 2010 at 1:09 PM, Paul LeoNerd Evans
wrote:

> Rather than a module, what are the thoughts/conventions/things I should
> know about, when considering putting an end-user application on CPAN?
>
> I've now had a number of comments requesting that my Circle IRC/etc..
> application go on CPAN.
>
>


Re: Yet another module naming suggestion query

2010-04-12 Thread David Nicol
On Tue, Apr 6, 2010 at 7:24 AM, Tim Bunce  wrote:

>
> On CPAN frameworks, especially generic ones with plugins etc., are
> encouraged to have "brand names". Think Catalyst, Mojo, Smolder, Plack,
> Dist::Zilla to name a few off the top of my head.


so it examines the hard drive and  notes the presence of what it is supposed
to look for, then issues a report in any of several computer-parseable
formats?

First off, I'd drop the serializer part and use a serializer library for
those, just to lower the maintenance burden (at the price of external
dependency -- season to taste)

Also, ++ to giving it a "brand name." It sounds kind of cloak-and-dagger,
like this module spies on the PC where it is installed and sends back
reports, like a foreign agent.  How about "Boris" after Boris of Boris and
Natasha from Rocky and Bullwinkle?

http://www.google.com/search?q=boris+badenov



-- 
question doubt


Re: When and how to throw exceptions?

2010-04-10 Thread David Nicol
On Fri, Apr 9, 2010 at 1:54 AM, Ovid
wrote:

> (Javaesque psuedo-code):
>
>  try {
>customer.read();
>  }
>  catch ( Exception::IO::NotFound e ) { ... }
>  catch ( Exception::IO::CantOpen e ) { ... }
>  catch ( Exception::IO::CantRead e ) { ... }
>  catch ( Exception::IO   e ) { ... }
>  catch ( Exception   e ) {
>panic("I don't know what type of exception I have!" . e);
>  }
>
> Yeah, the example is overkill :)
>
> The point here is that you try more specific exceptions first and drill
> down to less specific ones, including a "catch-all" exception.  However,
> what happens if you get rid of the "NotFound", "CantOpen" and "CantRead"? If
> the exception thrown is one of those types and assuming they're really
> subclasses of Exception::IO, then the "Exception::IO" catch will catch them
> rather the incorrectly falling through to the panic.  If these were merely
> shoved in a hash, you'd have to try to fall back to parsing either the
> messages (or the key) to figure out that you don't really have a panic.
>

I've never understood what's wrong with using string exceptions for this
kind of thing. Maintaining a discipline about properly dieing is required
both ways, and

 defined ($nextline = ) or die "IO CANTREAD: eof on INPUT?"'

seems more concise than abstracting an exception type hierarchy behind a
class hierarchy only to unabstract it later:

  eval {
   $customer->read(); 1
 } or do {{  # double openers to create block to last out of
 my $e = $@;
 $e =~ m/^io notfound/i and do  { ...; last };
 $e =~ m/^io CantOpen/i and do { ... ; last };
 $e =~ m/^io CantRead/i and do { ... ; last };
 $e =~ m/^io /i and do { ... ; last };
die "$e UNEXPECTED"; # filename, line number, newline added by die
 }};

Either way, you still need to maintain the meaning of the string prefixes or
the various exception types in a project-wide data dictionary.

I don't want to start (or restart) some kind of big argument; my
understanding is that coders coming from a Java background simply prefer to
use classes for everything.


Re: Trimming the CPAN - "Automatic Purging"

2010-04-04 Thread David Nicol
> It hasn't been done because its outside of the scope of design for rsync.
> It's meant to sync arbitrary filesets in which many, if not all, changes are
> made out of band.  It's decidely non-trivial to implement in that mode
> unless you're willing to accept a certain window in which your database may
> be out of date.
>
> But, in a situation like PAUSE, where the avenues in which files can be
> introduced into the file sets is controlled, it does become trivial.  It's
> the gatekeeper, it knows who's been in or out.

so the requirements for the Solution To The Problem Which Solves A
More General Problem Than The Immediate Problem And Will Therefore
Make Whoever Sets It Up A Hero include a replacement for the current
mirroring technology stack that is tailored to mirroring distributions
possibly including on-demand caching and expiration and that is
trivial to install -- something like

  perl -MCPAN -e 'install STTPWSAMGPTTIPAWTMWSIUAH::Mirrorsuite'
  nohup nice nice perl -MSTTPWSAMGPTTIPAWTMWSIUAH::Mirrorsuite -e
'mirror cpan.org .' &


Re: Trimming the CPAN - "Automatic Purging"

2010-03-31 Thread David Nicol
On Wed, Mar 31, 2010 at 7:43 AM, Ask Bjørn Hansen  wrote:
> The main point here is that we can't use 20 inodes per distribution.

so don't. How much reengineering would be needed to keep CPAN in a
database instead of a file system?


Re: Trimming the CPAN - "Automatic Purging"

2010-03-31 Thread David Nicol
On Wed, Mar 31, 2010 at 10:45 AM, David Landgren  wrote:
> On 31/03/2010 06:52, David Nicol wrote:
>
>> new proposal: Make modules "pay rent" in order to remain on a mirror.
>> Rent could be in the form of actual user interest, or good reviews.
>>
>> Use as a dependency could count as rent.
>
> Put a value tag on things and people will game the system to ensure their
> files are up on top. Doomed to failure.

I'm not suggesting that there be any kind of who-is-on-top game, the
game is who falls out the bottom. If someone cares enough to want to
game the system to ensure their files don't fall out, those files will
surely stay.  "pay rent" here is intended to mean something like
tracking usage over a long period in order to authoritatively identify
"old and useless" based on metrics and a policy.  Especially combined
with a Dnews-like trick file server that's really a cache and only
stores things people actually ask it for, which responds to the OP's
pain as I understand it, which is a frustration that their CPAN mirror
contains a lot of cruft. Although it still isn't clear why that is a
problem.

Purpose-based partitioning could be performed like deferred sidewalks:
put the pavement where the students make the trails in the grass.


what's a good name for a pure-perl OnScopeExit mechanism?

2010-03-30 Thread David Nicol
local_onExit is how it is now
http://davidnicol.diaryland.com/onExit.html
The semantics should be exactly the same as Scope::OnExit, but the
syntax is somewhat convoluted, abusing the C mechanism as it
does.

Scope::OnExit::PurePerl would seem to imply the same syntax, which
would be misleading.


-- 
question doubt


Re: Trimming the CPAN - "Automatic Purging"

2010-03-30 Thread David Nicol
On Sun, Mar 28, 2010 at 2:32 PM, Elaine Ashton  wrote:
>
> On Mar 28, 2010, at 12:48 PM, Randy Kobes wrote:
>
>>
>> Has some sort of disk quota system for CPAN author accounts ever been 
>> considered?
>
> Not specifically, no, at least not that I'm aware of. That would have to be 
> implemented on PAUSE and quotas frequently end up not solving the real 
> problem and create a headache both for the sysadmin and the users.

new proposal: Make modules "pay rent" in order to remain on a mirror.
Rent could be in the form of actual user interest, or good reviews.

Use as a dependency could count as rent.

Or simple downloading.  A mirror server that functioned more as a
cache than a mirror would also work: only the files that are actually
requested need be stored, as long as the mirror server knows how to
get something else if requested.  If the root cause of The Pain turns
out to be "full mirroring" then do partial mirroring, and automate the
partition with a policy instead of trying to plan the partition.




-- 
question doubt


POSIX::bsearch

2010-03-08 Thread David Nicol
I demand a short round of applause!


-- Forwarded message --
From: David Nicol 
Date: Fri, Mar 5, 2010 at 12:55 PM
Subject: Re: Another optimization question: bsearch()
To:
Cc: Perl5 Porters 


On Wed, Mar 3, 2010 at 9:16 AM, karl williamson  wrote:
> His point was that there's no gain in POSIX.pm having a bsearch, as someone
> writing in Perl will just use a hash.  But then he started thinking about it
> some more, and sent me privately a possible reason to have a bsearch exposed
> to the Perl programmer, as in some cases it makes more sense to keep things
> in an array instead of a hash.

an exposed POSIX::bsearch would use the same kind of comparator
functions that C uses. The memory savings one could get from
using a sorted array of object pointers instead of saving the
temporary table from a Schwarzian transform would not be worth it in
my (or Karl's) estimation.

On the other hand, you can get a range of consecutive elements with a
bsearch, which you can't do with a hash table without a more complex
data structure and advance indexing on partial keys.

So I've just published POSIX::bsearch to CPAN, which provides POSIX
bsearch semantics (any matching element) in scalar context or extended
semantics (the range of elements, and by the way, what index they
started at and how many there were are available in documented package
vars) in array context.


Re: Help with naming a module

2010-03-04 Thread David Nicol
I like the word "Foliage." Also, there are many here among us who
cannot help but smirk at the sight of the word "shrubbery." Smirking
is good.


Re: RFC: Proposal to simplify, speed-up /i regex matching while fixing things

2009-12-27 Thread David Nicol
On Sat, Dec 26, 2009 at 7:37 AM, Dr.Ruud  wrote:
>>> Is there a module that provides a C keyword that foldcases its
>>> input?
>> No unfortunately not. Its a good idea tho, it would be useful.
>
> There is:
>
> perlapi
>  ibcmp_utf8
>  to_utf8_fold
>
> Unicode::UCD::casefold()

to_utf8_fold would be the thing to wrap and apply over a string or
multiple strings to create the subroutine exported by the module,
called foldcase or fc. I'd use it isntead of lc in code that parses
configuration files, allowing non-ascii keywords that could still be
case-insensitive.


Re: Why you don't want to use /dev/random for testing

2009-11-11 Thread David Nicol
there's always
http://fourmilab.ch/cgi-bin/Hotbits?nbytes=128&fmt=hex
although I don't know what their massively parallel availability is.
Probably less than google charts.

-- 
http://twitter.com/HankSwap tweets approximately every 36 hours using
random delays. Promotional excerpts are fair use!


Re: module name for test data?

2009-09-29 Thread David Nicol
you could put the word "corpus" in there somewhere, since you're
publishing some test data. For others to use it, who might be looking
for test data, that's what a corpus is in test data jargon (i
believe.)

Test::Corpus::audio::mpd

would set an example of publishing test data to CPAN under the
Test::Corpus prefix.


Re: I'd like a way to abandon a module

2009-08-13 Thread David Nicol
On Thu, Aug 13, 2009 at 7:38 AM, Andy Lester wrote:
>
> On Aug 13, 2009, at 6:43 AM, Adrian Howard wrote:
>
>> Make an "ABANDONED" PAUSE user and give modules to it?
>
> I thought of that, but unless somehow the modules came out of PETDANCE into
> ABANDONED's directory, I still look like the owner.

Rig some automation so ABANDONED verifies the legitimacy of the
abandonor, then gets the latest version, bumps the version number,
adds some THIS MODULE IS AVAILABLE FOR ADOPTION boilerplate, and
republishes?


-- 
"I don't listen to what art critics say. I don't know anybody who
needs a critic to find out what art is. " - Jean-Michel Basquiat


Re: lexical warnings question

2009-06-28 Thread David Nicol
On Sun, Jun 28, 2009 at 1:24 AM, Rafael
Garcia-Suarez wrote:

> No, it's not global : it's a magic variable that points at the current
> warnings for the statement being compiled (much like %^H and $^H point
> at the pragmas currently in effect at compile time).

and "Being Compiled" means all open scopes that are being compiled --
but how does it know
when to stop?  I have never been able to figure out how far up the
compilation stack a modification of %^H goes and why.

That is, if I write a simple pragma according to the instructions in
perldoc perlpragma, and invoke
it inside a scope, outside the scope the value does not revert.

What am I doing wrong?


Re: Naming advice for retry manager module

2009-04-21 Thread David Nicol
On Tue, Apr 21, 2009 at 3:11 PM, Bill Ward  wrote:
> Something like Object::Retry maybe?  Then things can inherit from it?

The proposed module sounds more like a has-a than an is-a.  Or maybe
just a new method that would get included in the caller's namespace.
Set the defaults at import time, then call it with a single coderef:


  use retry MIN_SLEEP => 3, MAX_SLEEP => 10,  TIMEOUT => 120
  my $asdf_server_connection;
  retry sub { $asdf_server_connection = connect ( (new socket), ...)
or die } # whatever


the retry::retry routine would be something like

   sub retry::retry($) {
  my $start_time = time;
  my $result;
   for(;;){
 eval { $result  = &$_[0]; 1 } and return $result;
 my $E = $@;
 $LOGGER and $LOGGER->( "$E invoked from @{[caller]}");
 time - $start_time > $TIMEOUT and die "$E\n";
 sleep ($MIN_SLEEP + rand ( $MAX_SLEEP - $MIN_SLEEP ))
  }
   }

Everything in all-caps would be retry:: package variables, or scalars
tied to a per-caller(1)[0] hash to mitigate AAAD surprises.  Or
incorporated into the particular Retry::Object, as you are wisely
suggesting.

I've written stuff like that often enough that it would be cool to be
able to have a standard name and API for it, too.

-- 
"Your appreciation is my glorious gratuity." -- Herman Melville on IP rights


Re: Module name suggestions? - automatic per-OS subclass

2009-03-25 Thread David Nicol
On Wed, Mar 25, 2009 at 10:25 AM, Jonathan Yu  wrote:

> Class::ForSystem, since it's not too long and conveys what the module
> is designed to do.


I'm for Class::ForSystem or Class::ForOS, with the magically included
per-OS packages being
under the proposed module, such as Class::ForOS::linux::File::Tail
which is what Class::ForOS would load the replacements out of, were
Class::ForOS used in File::Tail where $^O eq 'linux'.

Class::PerOS is also appealing instead of Class::ForOS.

How does it interact with AUTOLOAD?  Does it matter if it is used at
the top or bottom of the module, or in the middle? Is there a
possibility of other systems of alternatives that key on something
other than $^O (such as the ever-popular "use less ..." family of
imaginary modules, for declaring optimization priorities, which now
appears on CPAN, as documentation only) playing nice with
Class::PerOS, by providing hooks?

Class::Alternatives could be a framework for frameworks of providing
alternatives, of which Class::PerOS would be the first demonstration


Good coffee today, I guess :)

-- 
"I lived in Hannibal fifteen and a half years, altogether, then ran
away, according to the custom of persons who are intending to become
celebrated." -- Samuel Clemens


Re: Science, Engineering, Craft (was once: something about hash references)

2009-03-06 Thread David Nicol
On Tue, Mar 3, 2009 at 6:54 PM, Eric Wilhelm  wrote:

> Perhaps we should charge by the pound for CPAN modules?  Not
> lines of code, but some kind of metric which appropriately conveys heft
> (toughness/strength/finish are, of course, premium.)

Executions without problem?  That would be a hella software metric.
The pie would have to get spread really thin to even bother with it.
Maybe they made the wrong decision in '68 with regard to letting
vendors charge for software.  Better model: software is not a product;
the service is the product.  Software quality can (must?) be driven by
liability concerns?




-- 
"Nah, we straight."


Re: Name for barcode-reading module?

2009-02-23 Thread David Nicol
http://www.barcodehq.com/primer.html#READERS seems to indicate that
"decoder" would be the term to use.

On Sat, Feb 21, 2009 at 11:58 AM, sawyer x  wrote:
> I think Barcode::OCR depicts by the name exactly what it does. It does OCR
> of barcodes. Perfect. The rest I would have to open to read what they do
> exactly. Barcode::OCR is sself explanatory, IMHO.

But "doing OCR of barcodes" is ambiguous.  Optical character
recognition often captures style info as well as character sequences,
at least the one that came with my scanner a few years ago does, and
very well too -- scanning magazine articles into pdfs resulted in
images that looked just like the pages, except that the text in the
middle of the page was clipboardable while towards the spine, where
things got skewed, there was a big vertical image -- I was, and
remain, impressed.  Based on that as an experience with OCR, I might
expect Barcode::OCR to somehow allow barcodes to pass through an OCR
process intact, perhaps by adjsuting image compression parameters
within their boundaries.

I think Barcode::Decoder depicts by the name exactly what it does. It
decodes barcodes. Perfect. The rest I would have to open to read what
they do exactly. Barcode::Decoder is sself explanatory, IMHO.


-- 
Freedom's colors are red, white and black and blue.


Re: RFC: String::Tagged

2009-01-30 Thread David Nicol
On Fri, Jan 30, 2009 at 2:46 PM, Paul LeoNerd Evans
 wrote:
> On Fri, Jan 30, 2009 at 02:00:13PM -0600, David Nicol wrote:
>> there is also intersection with the concept of "ropes" rather than
>> "strings" as I understand the term,
>
> A rope is a data structure designed to make string concat an O(1)
> operation, where you store a tree, or a linked list of substrings.
>
> That isn't the case here - in fact, the string data itself is just
> stored in here as a single perl string. The tags are stored in as a list
> of [start, length, name, value] objects beside it.

The other advantage is that the substrings can have attributes.


Re: RFC: String::Tagged

2009-01-30 Thread David Nicol
there is also intersection with the concept of "ropes" rather than
"strings" as I understand the term,


Re: Module for base 85 encoding

2008-11-24 Thread David Nicol
On Mon, Nov 24, 2008 at 1:26 PM, David Nicol <[EMAIL PROTECTED]> wrote:
> present in Mr. Clark's to-be-unveiled String::Base85 module.  Unless

I meant to write String::Ascii85, I stand with Darian Anthony Patrick
in that preference.


Re: Module for base 85 encoding

2008-11-24 Thread David Nicol
On Mon, Nov 24, 2008 at 12:56 PM, Bill Ward <[EMAIL PROTECTED]> wrote:
> How about contacting the owner of Math::Base85 and see if you can somehow
> join forces?  It seems to me this would make sense to have a single module
> that can output in either format.

1: RFC 1924 is an April fool.  Those who are not aware of that need to be.
See http://en.wikipedia.org/wiki/Ascii85#RFC_1924_version

2: "joining forces" or subclassing Math::Base85 or otherwise using it
is silly as it would create a finished good containing more glue than
wood.  http://search.cpan.org/src/TMONROE/Math-Base85-0.2/Base85.pm
reveals two trivial functions, both quite readable and therefore not
particularly inspired in terms of efficiency hacks; for instance the
letter<=>number encoding could be done as an array of values indexed
by chr($d) or pack/unpack with the "N" specifier for translating
between binary strings and 32-bit big-endian, presumably both features
present in Mr. Clark's to-be-unveiled String::Base85 module.  Unless
he followed MIME::Base64's example closely and wrote them in C.



-- 
signature closed for repair


Re: Integrating license related things of CPAN

2008-10-27 Thread David Nicol
On Sun, Oct 26, 2008 at 1:08 AM, Jonathan Rockway <[EMAIL PROTECTED]> wrote:


>  If I use Term::ReadLine and it picks the
> Term::ReadLine::Gnu, is my module GPL now?

JR may neither know nor care, but I think I know and I'd like to hear
about it if I've got it wrong.

No.  You haven't distributed Term::ReadLine::Gnu.  Making you a party
to the goings-on in someone else's domain because you set up the
possibility for that someone else to do something that they did is
absurd.

-- DN


Re: What's up with all these people uploading stuff under their own name.

2008-10-13 Thread David Nicol
As someone who claimed a top level CPAN domain and have been uploading
things into it since (Tipjar::) some time ago, the reasons are:  (1)
"branding" good things (2) not sure if my basic things deserve to be
at top level status (tipjar::fields) which is a policy I have
abandoned (Macrame)


Re: Regulating Module Authorship

2008-09-22 Thread David Nicol
On Mon, Sep 22, 2008 at 4:03 PM, Aristotle Pagaltzis <[EMAIL PROTECTED]> wrote:
>> formal trust metrics can be gamed.  That's also how humans are
>> wired.
>
> Sure, but not to any useful extent if they are person-centric and
> there is no worthwhile gain. There is no spam in my RSS reader
> and none in my Twitter timeline.

Okay, I concede:  Once again I'm spouting straw men.  Last year's flap
with the possibly deliberate compromise of Debian ssh occurred at a high
ring of trust that would have been the same with or without formal metrics.

Or would formal metrics have raised flags early?

Please, readers of the lists to which I post, alert me off-list if you
feel David Nicol
has been too free in sharing hypothetical contrarian positions of
late; I'm experiencing
guilt about wasting people's valuable time.  (this, and the recent
flip-flopping WRT
autodie semantics.)


Re: Regulating Module Authorship

2008-09-22 Thread David Nicol
On Mon, Sep 22, 2008 at 10:57 AM, Aristotle Pagaltzis <[EMAIL PROTECTED]> wrote:
> * Dave Rolsky <[EMAIL PROTECTED]> [2008-09-22 17:55]:
>> Note that this differs from ratings, which I don't find very
>> useful at all.
>
> Agreed. And trust networking is how humans are wired anyway.

formal trust metrics can be gamed.  That's also how humans are wired.



-- 
Fifteen million dollars just isn't what it used to be


Re: Carp::nosigdie - needs a better name

2008-09-03 Thread David Nicol
On Wed, Sep 3, 2008 at 3:12 PM, Eric Wilhelm <[EMAIL PROTECTED]> wrote:
> Also, as a debugging tool, I would rather be able to just load the
> module from a perl option.

yes, absolutely.  Until I saw your usage example I did not get how you
use this handy tool.  Since the localizing is the thing you are trying
to catch, how about including that in the new, improved name?

Furthermore, you're enforcing a stricture, rather than enhancing Carp.
 Here's a briefly considered suggestion:

 perl -Mstrict::sigdie yourprogram.pl

Maybe some day this will be a best practice:

  use strict;
  use strict::sig::die;

calling it strict::sig::die opens up the strict::sig:: space for
future development of pragmata that enforce strictures about other
entries in %SIG, too.

hopefully the amount of wind that leaks in after this opening of the
door to discussion of best practices and $SIG{__DIE__} will not be
unmanageable.


Re: Carp::nosigdie - needs a better name

2008-09-03 Thread David Nicol
it could be documented as a suggested use case for Acme::Landmine



-- 
off-topic notices are almost universally, themselves, off topic.


Re: Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-13 Thread David Nicol
On Wed, Aug 13, 2008 at 3:09 PM, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
> I get paid by the number of CPAN modules released, so yes, this will be
> Devel::GetContext, one function per module :)

I laughed


> BM> If you want calls to every(5) to only return true once every five times
> BM> even across forked processes, your going to need some sort of IPC,
> BM> obviously.
>
> It's actually not hard to do, just tie the hash to a shared memory
> segment with Tie::ShareLite and ignore the $$ and context() uniqueness.
> But I really doubt Every.pm should provide it, it's a solution in search
> of a problem.

it depends how far out you want your everyness context to extend, one
might want to every on a condor cluster or something.


Re: Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-10 Thread David Nicol
On Fri, Aug 8, 2008 at 5:41 PM, Ben Morrow <[EMAIL PROTECTED]> wrote:
> [the interpreter address is] more unique than either pid or
> tid, and actually reflects 'Perl-level thread of control'.

I'm a little surprised; I thought that the interpreter address would
remain the same in both processes after a 'nix fork.


Re: Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-07 Thread David Nicol
On Thu, Aug 7, 2008 at 11:01 AM, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
> I plan to add the interpreter (Perl context, actually) address when I
> get a chance, Ben Morrow was kind enough to point out what I was
> missing.  Then it will be more correct than the current version.  Does
> anyone know if the context address is unique in mod_perl and with
> threads?  If not, what can I do?
>
> Ted

it seems like if it isn't, extending the instance key using the pid
and tid would be best made the application developers problem.

Suggesting an approach in the Devel::Callsite documentation by
providing example code that produces an instance key that will be
valid in forking and threading environments, would make more sense IMO
than spoiling Devel::Callsite's focus.

-- 
"don't let the perfect become the enemy of the good" -- some politician on CNN


Devel::Callsite is a better instance key than join $;,caller()[1,2]

2008-08-07 Thread David Nicol
=head1 NAME

Devel::Callsite - Get current callsite

=head1 SYNOPSIS

  use Devel::Callsite;
  sub $site { return callsite() };
  print $site->(), "\n"; # prints one number
  print $site->(), "\n"; # prints a different number

=head1 DESCRIPTION

This function returns the callsite (a number) one level up from where
it was called.  See the tests for an example.  It's useful for
functions that need to uniquely know where they were called, such as
Every::every() (see CPAN for that module).

=head1 HISTORY

Written by Ben Morrow on perl5-porters.  CPAN-ified by Ted Zlatanov.

=head1 AUTHOR

Ben Morrow <[EMAIL PROTECTED]>
Ted Zlatanov <[EMAIL PROTECTED]>

=cut

-- 
"don't let the perfect become the enemy of the good" -- some politician on CNN


Re: Port to PyConstructs

2008-07-14 Thread David Nicol
On Sat, Jul 12, 2008 at 1:50 AM, Shlomi Fish <[EMAIL PROTECTED]> wrote:
>
>
> > > http://construct.wikispaces.com/
>
> > In short, it's a library that parse binary structs.
>


Cool!
http://dev.perl.org/perl6/rfc/122.html


Re: Name space: throwing exceptions easily

2008-07-02 Thread David Nicol
On Wed, Jul 2, 2008 at 5:44 PM, Aristotle Pagaltzis <[EMAIL PROTECTED]> wrote:
> * Aristotle Pagaltzis <[EMAIL PROTECTED]> [2008-07-03 00:25]:
>>  No one would say that they are
>> trying to achieve slowness or inflexibility.

Drafted any mission-critical change control policies recently?


Re: Must exist, right?

2008-06-20 Thread David Nicol
this presumes a hash-based object instead of a field of a hash-based
object, but it can have blessed members unlike Chris Dolan's draft; it
also takes multiple args to be slice keys rather than consecutive
accesses into a deep AoA.  Wrapping in an import function and the
niftiness with closing over $fieldname has been left out,

UNTESTED.



package autoaccessor::ReadOnly;

sub new {
   shift; # lose package name
   bless shift #return what we were given, it had better be a hashref
}

sub AUTOLOAD{
   our $AUTOLOAD;
   $AUTOLOAD =~ /::DESTROY$/ and return;
   my ($fn) = $AUTOLOAD =~ m/([^:]+)\z/;
   my $obj = shift;
# closed-over fieldname trick goes here
   my @args = @_;
# without args, presume hash lookup of $fn
   @args or return $obj->{$fn};
# try access styles to see what works
   my @retval;
if (wantarray){
   eval [EMAIL PROTECTED] = @{$obj->[EMAIL PROTECTED];1} and return @retval;
   eval [EMAIL PROTECTED] = @{$obj->[EMAIL PROTECTED];1} and return @retval;
}else{
   eval [EMAIL PROTECTED] = @{$obj->[EMAIL PROTECTED];1} and return 
$retval[0];
   eval [EMAIL PROTECTED] = @{$obj->[EMAIL PROTECTED];1} and return 
$retval[0];
}
   Carp::croak( "Cannot figure out how to access $fn member of $obj")
}

1;
__END__

=pod

Andy A's initial example would become

   package main;

   my $my_foo = new autoaccessor::ReadOnly {
   foo => [ 1, 2, 3 ],
   bar => { eat => 'drink', sleep => 'wake' },
   };

   my $two = $my_foo->foo( 1 );
   my $drink = $my_foo->bar->eat;

=cut


Andy differentiation

2008-06-19 Thread David Nicol
Armstrong: Hexten, London.

Lester: Petdance, Chicago.


Re: Must exist, right?

2008-06-18 Thread David Nicol
Considering that Data::Dumper is entirely regular in how it will
present a deconstruction of the data structure, and you have a clear
concept of how you wish the example structure ===> accessor set thing
to work, it's certainly possible, and would take maybe two hacking
sessions to get right (provided you don't get swept into the lake by a
mini-tsunami.)

It seems like something that might not exist already, as the need to
share that kind of meta-abstraction is felt by only extreme show-offs
(such as various people on this list)

To make your example DWITYM, Data::Auto::Objectify::Thing would presume that
the structure returned by its caller has a C that will return a
fully populated example object when called with no arguments, and
would postpone defining the accessors until the INIT phase, because
the &{caller()::'new'} does not exist yet at C time.

I would have Data::Auto::Objectify::Thing take an optional C<< example
=> ... >> import arg in addition to the wait-until-INIT trick, and
would bless the substructures into constructed-named packages under
Data::Auto::Objectify::Thing::Packages::... for example.

Tipjar::fields creates accessors for named fields by imposing array
object semantics on its calling package; recently I prefer to use
:lvalue subroutines for accessors rather than defining both get* and
put* s.

In your example, you are planning on subclassing MyFoo into a whole
family of kinds of hash-based objects that share this accessor set, or
something.  It's not clear if the elements are supposed to be
extensible or not.  If they aren't extensible, and there is a fixed
set of them, using an array-based object and naming all the slots with
lvalue accessors is the way I would do it

sub new { bless [], shift };
BEGIN{
   my $counter = -1;
   eval join '' map {$counter++; <[$counter] }
ACCESSOR
};

but of course I don't know exactly what you are trying to do.


Re: How to declare dependency on other modules?

2008-04-12 Thread David Nicol
On Fri, Apr 11, 2008 at 5:39 PM, Ricardo SIGNES
<[EMAIL PROTECTED]> wrote:
>
>  I don't see a really good way to automate this.
>
>  --
>  rjbs

start with an index of packages to distributions, grep the module source
for C statements, there you are.  The function that converts the list
of use statements into the dependency list would be yet another thing
that the cpan.org web site does, and creating the draft section of the
Makefile.PL file or equivalent could be achieved, from the module author's
perspective, with something like "make cpandep."


Re: Removing or Archiving outdated and unsupported modules on CPAN; proposal

2008-04-03 Thread David Nicol
> > > > "Will you green-light my unfunded mandate?"

> > > Hell, no.

I had no problem parsing the rude dismissal as acceptable hyperbole.
The author of the dismissal had patiently replied to a bunch of points
and in my opinion by doing so earned wnough credibility points to
spend a few venting.  I smiled at the rude dismissal.


-- 
bringing useful insights from Computer Science to the larger world


Re: Ideas for soc, Looking for mentors

2008-03-18 Thread David Nicol
shorewall-perl might be a place to start; shorewall comes up zero on
cpan search, yet is
a big perl program; so converting it to an O-O module should be a
simple matter of
time and coffee :)

On Tue, Mar 18, 2008 at 5:20 PM, Eric Wilhelm
<[EMAIL PROTECTED]> wrote:
> # from Juan Luis Belmonte
>  # on Tuesday 18 March 2008 14:19:
>
>  >Im thinking in a module to manage iptables in an object oriented, and
>  >dynamic way.
>
>  Hi Juan,
>
>  That sounds like an interesting idea.  Have you looked on CPAN,
>  sourceforge, etc for prior art?


-- 
At the bottom of this huge heap of promotional strategies, there's a
product trying to chew its way out


Re: Distributing C code

2008-03-17 Thread David Nicol
On Mon, Mar 17, 2008 at 12:45 PM, Guy Hulbert <[EMAIL PROTECTED]> wrote:
> Inline::C may be easier but I don't know how much it is used.

It's used less than it used to, thanks to this guy:

InlineX::CPP2XS
Convert from Inline C++ code to XS.
InlineX-CPP2XS-0.12 - 19 Sep 2007 - Sisyphus

InlineX::C2XS
Convert from Inline C code to XS.
InlineX-C2XS-0.12 - 19 Sep 2007 - Sisyphus


P($n,$r) and C($n,$r)

2008-02-04 Thread David Nicol
I've written a couple of little recursive routines that provide
arrays or arrayrefs of arrayrefs of all the possible permutations
and combinations, of sets of n items, counting from 0 to n-1,
and wondering if such a thing is worth cluttering up CPAN with.

I'm using them for this crazy four-dimensional chess board...


-- 
A vote for anyone other than Ron Paul is a vote to continue paying income tax


Re: Naming convention for thin wrappers around C lib.so ?

2007-12-10 Thread David Nicol
On Dec 10, 2007 5:17 AM, Dominique Quatravaux <[EMAIL PROTECTED]> wrote:
>
> +1, imho it makes good sense to have (some future version of)
> Cache::Memcached depend on Lib::Memcached.

me too


Re: With the Macrame macro system, Perl may now be a Lisp.

2007-12-06 Thread David Nicol
On Dec 6, 2007 6:23 PM, Bill Ward <[EMAIL PROTECTED]> wrote:
> Cute experiment, but I REALLY hope nobody tries releasing useful
> modules to CPAN that depend on this...

Thank you

After it has line number support it will be more practically useful.

I'm sort of stuck on how much records of line numbers of expanded rewrites to
keep and how to encode them into the "filename" portion of the #line comment.

imagine:

#line 1000 fileF.pl
use Macrame; # line comments apply to the next line; this is line 1000
macro cheddar {"cheese"}
warn cheddar;
macro warn_wisconsin { warn cheddar}
warn_wisconsin;
__END__

the easiest thing is to keep line number information that
is available during lexing and output the line number
whenever it changes in the stringification:
#line 1002 fileF.pl
warn "cheese";
#line 1003
warn "cheese";
__END__

next tricky is to have an macros inherit their line numbers
from wherever they are invoked, giving
#line 1002 fileF.pl
warn "cheese";
#line 1004
warn "cheese";
__END__
even if the warn_wisconsin macro is several lines long

is it worth the trouble to have warnings inside macros show
a full expansion history as a debugging aid?  That's the current
goal for the next release, with a history syntax of appending
something to the filename portion of the eventual comment:

#line 1002 "fileF.pl"
warn "cheese";
#line 1004 "fileF.pl:1003"
warn "cheese";
__END__

when macros start appearing in different files from where
they are expanded, the debugging comments will start
looking something like

#line 765 "applicaiton.pl:maclib.pm:8970:234:basic_macros.pm:22"



-- 
"Common sense has prevailed"


Re: With the Macrame macro system, Perl may now be a Lisp.

2007-12-01 Thread David Nicol
On Dec 1, 2007 2:22 PM, Joshua ben Jore <[EMAIL PROTECTED]> wrote:
> On Dec 1, 2007 8:51 AM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> > From:   "David Nicol" <[EMAIL PROTECTED]>
> > > On Nov 30, 2007 7:24 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> > > > I'm missing the reason-for-being of the module it its docs. I read
> > > > the whole documentation and the test script and I still don't get it.
> > > >
> > > > What is it supposed to be used for?
> > > >
> > > > Sorry, Jenda
> > >
> > >  polymorphic functions / more complex prototypes
> >
> > Any examples?

Currently when you want to have a sub act differently depending on
how many arguments are supplied to it, rather than the naive

   sub  poly($) { print "got one arg, @_\n" }
   sub  poly($$) { print "got two args, @_\n" }

working as intended, you have to do something like

   sub  poly($;$) {
  @_ == 1 and return print "got one arg, @_\n";
  print "got two args, @_\n"
   }

Using Macrame, you can do

   sub  _poly1arg($) { print "got one arg, @_\n" }
   sub  _poly2arg($$) { print "got two args, @_\n" }
   macro poly(one,two) { _poly2arg(one,two) }
   macro poly(one) { _poly1arg(one) }
   macro poly one,two { _poly2arg(one,two) }
   macro poly one { _poly1arg(one) }

> > >  creating new syntax without dealing directly with unlexed source

internal syntax for Macrame, for example.  A good deal of thought went
into selecting "everything up to and including the next semicolon" as the
signature for EXPAND.  This means that if you  want EXPAND to look the
same as BEGIN, END, INIT, et cetera, you could define

   macro EXPAND '{body}' {EXPAND body ;}

Macrame is envisioned as the basis for the TERN project, which intends to
rewrite perl in perl by defining a set of macros that rewrite more complex
source code constructions using simpler ones (the motivations for this
project aren't very strong, which is how it has been largely backburnered
for a very long time)

For instance, the trailing if syntax

 print "flag true\n" if $flag;

might  be expressable using standard if, so that a macro could be defined
that would rewrite the above line to

$flag and print "flag true\n";

at the source filtering pass rather than later on where that is done now.  That
is not a really good example for version 0.08 because there is no way to
specify either an infix macro or a greedy macro argument at this time; both
of those features are on the wishlist.

Most features proposed in 2000 on the perl6 language brainstorming
mailing list would be suitable candidates for implemetnation using macros

A feature I believe can be added using 0.08 syntax is the idea of having
"my" create a reference

 macro my \$alias = \$Item; {
my $alias;
$alias = \$item;
macro alias { {NOMACROS $alias} } # from here on, $alias is
"really" ${$alias}
}

which may sort of work at this point.


> > Looking at the KNOWN BUGS it doesn't look like this works too well.
> > Any examples of a "new syntax" that you would like to be able to
> > create? So that we can see how close would we be able to get without
> > using source filters.

Macrame _is_ a source filter; it provides a filtering syntax that abstracts away
some parsing steps.

> > >  inlining small oft-used code snippets without all those pesky function 
> > > calls
> >
> > "Premature optimization is the root of all evil."
> > OTOH, being able to inline functions could be nice, yes.

Yes, with Macrame you can have both inlined data access and detail hiding.

> You ought to check out Scott Walter's Code::Splice then. When I last
> talked to him it worked well when applied at the statement level. That
> is, your insertion point is at a statement level and I gather it'll
> take a full sub and inline it. And other stuff but I forget what.

Macrame is not limited to statement or expression level; I will include
this in  the see also section in 0.09.

David Nicol
-- 
wheels reinvented while-U-wait


Re: With the Macrame macro system, Perl may now be a Lisp.

2007-11-30 Thread David Nicol
On Nov 30, 2007 7:24 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> I'm missing the reason-for-being of the module it its docs. I read
> the whole documentation and the test script and I still don't get it.
>
> What is it supposed to be used for?
>
> Sorry, Jenda

 polymorphic functions / more complex prototypes

 creating new syntax without dealing directly with unlexed source

 inlining small oft-used code snippets without all those pesky function calls

 perl advocacy to Lisp snobs (':)')




-- 
wheels reinvented while-U-wait


With the Macrame macro system, Perl may now be a Lisp.

2007-11-29 Thread David Nicol
Macrame 0.08 finally passes a variety of tests and has been uploaded.

Please harangue it via rt.cpan.org.


what's the right way to test a source filter?

2007-08-07 Thread David Nicol
so I am closer than ever to releasing my way-cool source filter module,
which is based on Filter::Simple.  Big question:  how do I write the test
script?


Re: Name for "EscapeCage"

2007-06-30 Thread David Nicol

On 6/30/07, Eric Wilhelm <[EMAIL PROTECTED]> wrote:


A dangerous animal in a sandbox will probably get out.



so the most standard term i believe is "jail"


Re: Name for "EscapeCage"

2007-06-29 Thread David Nicol

On 6/29/07, Bill Ward <[EMAIL PROTECTED]> wrote:


No a sandbox is where you have a practice area where changes made have
no lasting impact.  For example ebay and paypal have sandbox areas
where you can experiment with applications that use those services
without actually buying anything.  This is more of a quarantine.


http://en.wikipedia.org/wiki/Sandbox_%28disambiguation%29
lists both a computer_security and software_development variant.


Re: Name for "EscapeCage"

2007-06-29 Thread David Nicol

String::Sandbox  ??


Re: Need naming advice

2007-06-26 Thread David Nicol

does it do SSO?


> > It provides a generic user account management system, with features such as:
> [...]>


Re: line numbers with Filter::Simple

2007-06-01 Thread David Nicol

On 6/1/07, Rocco Caputo <[EMAIL PROTECTED]> wrote:

caller() is a good solution.  I use it, Filter::Util::Call, and some
involved #line magic to maintain sane line numbers in
Filter::Template.


I am preprocessing the code to add line number identifiers between
all lines, then when I process the code I pull them out and tag all my
lexemes with line numbers, and remove the line number IDs from
the quotelike array.  In a routine invoked by FILTER_ONLY, the
initial line appears to be caller(3)[2]

here's my line numbering code, from soon to be released Macrame.pm recursive and
lexical macro system

Like the name?  I think its better than Macro::sweet, which was the runner-up
in my fevered brain :)


sub doMacrame{
$_ = (transform treeify($_))->Stringify;
};

sub AddLineNumbers {
my ($line, $file) = caller(3)[2,1];
my @lines = split /\n/, $_;
my @linesout;
for (@lines){
if (  # see perldoc perlsyn
/^\#   \s* line \s+ (\d+)   \s* (?:\s("?)([^"]+)\2)? \s* $/x
){
($line, $file) = ($1,$3);
$file =~ s/([^\w\/\\-\.])/sprintf("#%X#",chr($1))/ge;
next;
};

#   push @linesout,  $line++, '"$file"');
#   $source =~ s/^#line (\d+) "(.+)"/__Macrame_LINE($1,$2)/mg;
push @linesout, '__Macrame_LINE('. $line++.",$file)";
push @linesout, $_;
};
$_ = join "\n", @linesout;
};

FILTER_ONLY
all => \&AddLineNumbers,
code => \&doMacrame,
all => sub {
print  "begin filter output-\n";
print;
print"\n-- end filter output\n";
};


line numbers with Filter::Simple

2007-05-30 Thread David Nicol

We can declare a line number, in source code, like so
# perl <
#line 54
die smiling
foo

smiling at - line 54.
#

and counting newlines within a Filter::Simple code block is easy enough

but how do I find out what line to start at, so I can insert #line comments
into my filter output that will match the input?  I am about to experiment with
caller(N) to see how many frames back to go, then I'll use that, but I am asking
here in case anyone knows a better way.


Re: taxonomy for data-structure modules?

2007-05-27 Thread David Nicol

On 5/26/07, Ken Williams <[EMAIL PROTECTED]> wrote:


I think that's part of it.  But another problem is that many people
don't know the "official" names for the data structures they're
thinking of, e.g. "trie" or "skiplist" or whatever, so they can't
search very effectively for it.

It does seem like a user-applied keyword tagging scheme on CPAN (e.g.
search.cpan.org) would be very fruitful and would go a long way
toward solving a lot of the organization-related problems people
bring up on this list.

  -Ken


Does perlmonks have a wiki with a data structures section?  Wikipedia
has loads of data structures documents on it -- for instance,
http://en.wikipedia.org/wiki/Skiplist has links to SkipDB and an implementation
in C#.  Creating a norm of linking data structure modules from the wikipedia
article on the structure in question would do the trick using existing
infrastructure,
as would other proposals that do not demand tiers of new services appear from
nowhere.


Re: peer review for first CPAN module? (JavaScript minification)

2007-05-25 Thread David Nicol

On 5/25/07, Joshua ben Jore <[EMAIL PROTECTED]> wrote:

You may want want to convert from UTF16 to perl native strings, then
convert back. JavaScript is defined as being stored in UTF16 but
that's kind of unusual elsewhere. Isn't it?


As Dr. Ruud said; also, ECMAscript engine authors (at least
David Leonard) seem to regard normalizing everything to UTF8
as equally bizarre. The Xerxes XML parser, for instance, uses 16
internally.


anybody feel like translating some PHP to Perl?

2007-05-25 Thread David Nicol

http://news.com.com/2100-1029-6186430.html
--
"It is not possible to make a mistake." (customary greeting given by
Bokononists when meeting a shy person)


Re: (Create a new ?) namespace for applications on CPAN

2007-05-24 Thread David Nicol

On 5/23/07, Andy Lester <[EMAIL PROTECTED]> wrote:

I meant about his irrelevant parallels to "program" being what you
get at the opera, and "script" the lines of a play.


So if you find non-geek usage irrelevant, what is the scope of the
target demographic whose usage you seek to correct then?

--
"It is not possible to make a mistake." (customary greeting given by
Bokononists when meeting a shy person)


"script" or "program"?

2007-05-22 Thread David Nicol

On 5/22/07, Andy Lester <[EMAIL PROTECTED]> wrote:


On May 22, 2007, at 11:07 AM, David Nicol wrote:

>> > I'm trying hard to get people to stop saying "script" when
>> > referring to their Perl programs.  I'd prefer that we not use it
>> > anywhere at all.
>
> outside of computers, "script" is a better term for the carefully
> tuned deliverables that software engineer produce than is
> "program."  Your basic mundane citizen considers a "program"
> a list of things that will occur in an evening, or a document
> they are handed when they occasionally get out to the opera,
> while "script" is something mysterious, yet cruciual for
> the production of television shows, produced by professionals
> who are legendary for failing to get the girl.

None of that has any bearing on the sort of change in thinking I'm
working on.


Okay, Andy "Petdance" Lester, vent your spleen.  We're all ears.


Re: (Create a new ?) namespace for applications on CPAN

2007-05-22 Thread David Nicol

On May 17, 2007, at 4:08 PM, Andy Lester wrote:
> I'm trying hard to get people to stop saying "script" when
> referring to their Perl programs.  I'd prefer that we not use it
> anywhere at all.


outside of computers, "script" is a better term for the carefully
tuned deliverables that software engineer produce than is
"program."  Your basic mundane citizen considers a "program"
a list of things that will occur in an evening, or a document
they are handed when they occasionally get out to the opera,
while "script" is something mysterious, yet cruciual for
the production of television shows, produced by professionals
who are legendary for failing to get the girl.


towards TERN::macro (was Re: LISP module from CPAN)

2007-05-10 Thread David Nicol

On 5/10/07, Adrian Howard <[EMAIL PROTECTED]> wrote:


On 9 May 2007, at 21:37, David Nicol wrote:
> [proposed macro syntax example:]
> macro hashkeyaccessor(fieldname) {   sub fieldname { $_[0]->
> {fieldname}}  };
> hashkeyaccessor $_ for qw/FIELD NAMES GO HERE .../;
>
> [summary of benefits of approach]  What am I missing?

You're missing that you can execute code at compile time that
determines what code you generate.


I disagree, I think I included that, and you didn't see that I had.

so to be fully lispy the extension would need to support

defmacro keylookup(key) { $_[0]->{key}}
defmacro hashkeyaccessor(fieldname) {   sub fieldname {
(keylookup fieldname) }  };
(hashkeyaccessor $_) for qw/FIELD NAMES GO HERE .../;

as well as




www.gigamonkeys.com/book/macros-defining-your-own.html

Some devils brew of source filters and eval is the closest you'll get
in Perl 5 Perl 6 with its explicit lexer/parser should give you
the full power of Lisp style macros.


the debate response to that is, "show me something besides
syntax succinctness you can do with a LISP macro that you cannot
do with such a code-generated string eval"


Adrian (recovering Smug Lisp Weenie :-)


That's fun link, the story of Mac the programmer, who eventually retires.  The
article contains this:

* When you write macros, you're writing programs that will be
* used by the compiler to generate the code that will then be
* compiled. Only after all the macros have been fully expanded
* and the resulting code compiled can the program actually be run.
* The time when macros run is called macro expansion time; this
* is distinct from runtime, when regular code, including the code
*  generated by macros, runs.

this separation of times sounds exactly the same as putting
an eval of generated source in a BEGIN block.  Adding a source
filter to the brew has to potential to allow for succinctness and
clarity that is absent from the generated source situation due
to the trickiness of escaping sygills appropriately  (easy to get
wrong, but you only have to get it once right, then it stays
working)

Later in the chapter, gigamonkeys admits that LISP macros also
suffer from the fact the human brain was not originially designed for
programming computers:
* In other words, you'll write a macro-writing macro: a
* macro that generates code that generates code. While
* complex macro-writing macros can be a bit confusing
* until you get used to keeping the various levels of code
* clear in your mind

LISP feature:  macros that produce macros.
Perl equivalent: evalling generated source to produce functions to
eval generated source.
Can do it, yes.  And it is a slightly bigger PITA than using LISP syntax.

If I find the time to put what I learned about source filters while
exploring writing a tail recursion optimizer (final result:  there
are too many edge cases: if you really want tail recursion
optimization, learn about C and use it) into
making my own macro syntax filter which will work as
exampled above, it will work as follows:

(1) remove pods and comments and abstract out quoting constructs;
(2) identify defmacro constructions, whatever they look like, convert
them to coderefs that take parameters and return the body as
evallable strings;
(3) identify expressions including defined macros, and run those
expressions immediately
(4) expand macros, even embedded in expressions, in results from (3)
(5) allow for macros declared in macro expansions to join the list
of declared macros from that point on
(6) allow for lexical scoping of macros
(7) allow for predeclaration of macros (? is this useful)
(8,...) extend macro language


What's already on CPAN:
http://search.cpan.org/~segv/Macro-0.2/Macro.pod
Essentially what I'm describing, but with a clunky Parse::RecDescent
syntax that may be more complex than doing it yourself; and with
a bugs/todo list at the bottom that restates various points made
above -- I will  start with Macro-02 instead of from scratch if I do this

http://search.cpan.org/~autrijus/Filter-Macro-0.11/lib/Filter/Macro.pm
misleadingly named, Filter::Macro appears to be Pollute::Persistent
plus hints accomplished through source filtering.

TERN (The Extensible Rewriting Notation) mailing list,
http://lists.nongnu.org/mailman/listinfo/TERN-discuss

The "Take away David Nicol's internet access committee"
mailing list, (...)

--
practical solutions to systemic problems


Re: LISP module from CPAN

2007-05-09 Thread David Nicol

so if there were lisp-like macros available in perl, my sugar example
might be something like the following?

macro hashkeyaccessor(fieldname) {   sub fieldname { $_[0]->{fieldname}}  };
hashkeyaccessor $_ for qw/FIELD NAMES GO HERE .../;

and I would save the trickiness of getting the interpolation level
right.  That is
imagining a CPP macro...  the LISP idea on macros is that the template
would be created at the optree level rather than the source level, but its still
a template and replacement kind of deal.  What am I missing?


Re: LISP module from CPAN

2007-05-09 Thread David Nicol

On 5/9/07, Vadim <[EMAIL PROTECTED]> wrote:

I consider eval "$string" as a replacement of macros.


for instance,  I did the following in a curl wrapper package, to make
the curlies optional around the fieldnames:

   BEGIN { for (qw/
  BUFFER CALLBACK DATA EVENT FAILURE FETCHTIMEOUT
  GET MAXAGE MAXSTALE MESSAGE NOCACHE POST
  READY STARTED UH URL USER/){
  eval <{$_}
 }
FIELD
   }}

What would that look like in LISP?


  1   2   >