Re: cpan you have to see

2012-12-15 Thread Abigail
On Wed, Dec 12, 2012 at 09:45:25PM +, DAVID HODGKINSON wrote:
 
 Would hurling a PBP test at the whole of CPAN to get a metric be of any 
 benefit?
 


That would violate the spirit of the PBP, which clearly states that
its rules shall not be taken as gospel, but as starting points to
make up your own mind.

Considering how people are treating the PBP, I think the book has
more damage that it has done good.




Abigail


Re: cpan you have to see

2012-12-15 Thread Abigail
On Sat, Dec 15, 2012 at 12:23:29AM +, David Cantrell wrote:
 On Wed, Dec 12, 2012 at 05:23:23PM +, Edmund von der Burg wrote:
 
  Each language has its own idioms and ways to do things. In shell
  scripting the while true ... done loop is one of them.
  
  In Perl the equivalent would be while (1) {  }
 
 Although true is 0 in the shell ...
 
 $ true;echo $?
 0
 $ true  echo it was true
 it was true
 
 which is bloody irritating.
 


Nah, it's doing the right thing.

One has a single byte to determine success or failure. The convention
is to use a single value to determine success, and the rest to specify
why there is a failure. And then the shell makes its boolean operators
do the right thing.

It be utter madness to have programs exit '0' on failure, and given 
them 254 different exit values to indicate in which way they were
succesful.


Abigail


Re: cpan you have to see

2012-12-15 Thread DAVID HODGKINSON

On 15 Dec 2012, at 08:40, Abigail abig...@abigail.be wrote:

 On Wed, Dec 12, 2012 at 09:45:25PM +, DAVID HODGKINSON wrote:
 
 Would hurling a PBP test at the whole of CPAN to get a metric be of any 
 benefit?
 
 
 
 That would violate the spirit of the PBP, which clearly states that
 its rules shall not be taken as gospel, but as starting points to
 make up your own mind.

It's kwalitee. It's just a metric.

Like running coverage measurement on tests. It tells you where the gaps
are. Heh, maybe another metric for the smoker.




Re: cpan you have to see

2012-12-15 Thread Daniel de Oliveira Mantovani
It should be fake, is impossible someone be so idiot.

On 12 December 2012 05:29, Uri Guttman u...@stemsystems.com wrote:
 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/

 in particular the boolean stuff is amazing and the print stuff isn't far
 behind.

 uri



-- 
If you’ve never written anything thoughtful, then you’ve never had
any difficult, important, or interesting thoughts. That’s the secret:
people who don’t write, are people who don’t think.



Re: cpan you have to see

2012-12-15 Thread Daniel de Oliveira Mantovani
sorry I realize this is not a joke and this is a newbie code.
I truly believe we should support newbie people, sorry again.
(I read just the first email)

On 15 December 2012 15:01, Daniel de Oliveira Mantovani
daniel.oliveira.mantov...@gmail.com wrote:
 It should be fake, is impossible someone be so idiot.

 On 12 December 2012 05:29, Uri Guttman u...@stemsystems.com wrote:
 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/

 in particular the boolean stuff is amazing and the print stuff isn't far
 behind.

 uri



 --
 If you’ve never written anything thoughtful, then you’ve never had
 any difficult, important, or interesting thoughts. That’s the secret:
 people who don’t write, are people who don’t think.



-- 
If you’ve never written anything thoughtful, then you’ve never had
any difficult, important, or interesting thoughts. That’s the secret:
people who don’t write, are people who don’t think.



Re: cpan you have to see

2012-12-14 Thread David Cantrell
On Wed, Dec 12, 2012 at 05:23:23PM +, Edmund von der Burg wrote:

 Each language has its own idioms and ways to do things. In shell
 scripting the while true ... done loop is one of them.
 
 In Perl the equivalent would be while (1) {  }

Although true is 0 in the shell ...

$ true;echo $?
0
$ true  echo it was true
it was true

which is bloody irritating.

-- 
David Cantrell | Godless Liberal Elitist

PLEASE NOTE: This message was meant to offend everyone equally,
regardless of race, creed, sexual orientation, politics, choice
of beer, operating system, mode of transport, or their editor.


Re: cpan you have to see

2012-12-14 Thread David Cantrell
On Wed, Dec 12, 2012 at 09:45:25PM +, DAVID HODGKINSON wrote:

 Would hurling a PBP test at the whole of CPAN to get a metric be of any 
 benefit?

It would certainly be interesting.

-- 
David Cantrell | even more awesome than a panda-fur coat

  NANOG makes me want to unplug everything and hide under the bed
-- brian d foy


Re: cpan you have to see

2012-12-14 Thread Paul Makepeace
On Fri, Dec 14, 2012 at 4:23 PM, David Cantrell da...@cantrell.org.uk wrote:
 $ true  echo it was true

This makes sense. Think of true as thing that succeeded rather
than OMG it's 0 so must be false!!1!

Ruby treats everything as true unless it's nil or false (so yes, 0 and
'' are true). Bit weird to get used to but all this other nonsense
goes away.

Paul


Re: cpan you have to see

2012-12-13 Thread Mallory van Achterberg

Ug, what I get for sending a mail while still browsing it :P

-Mallory


Re: cpan you have to see

2012-12-13 Thread Andrew Beverley
On Wed, 2012-12-12 at 17:45 +, Gareth Harper wrote:
 Without commenting on the function of the modules (I personally
 wouldn't use them, but I can see what you're trying to accomplish).
 Style/function/speed wise there certainly are a few areas which you
 may want to address.  I'll explain some of the more obvious ones here,
 though there are several other things you may want to look at.  I see
 several other people have volunteered help as well.

[...]

Wow, thanks for that Gareth. A very well written and comprehensive
email.

Andy




Re: cpan you have to see

2012-12-13 Thread Aaron Trevena
On 12 December 2012 21:45, DAVID HODGKINSON daveh...@gmail.com wrote:
 Do we still have automated kwalitee on CPAN?

There is CPANTS (http://cpants.charsbar.org/index.html) which checks Kwalitee

 Would hurling a PBP test at the whole of CPAN to get a metric be of any 
 benefit?

As already mentioned Perl Critic could be done, but perhaps with a
very high tolerence level and focus more on big mistakes and risks
than good style - certainly feasible (McCabe score in 3 digits, much
more useful than whether bare, explicit or implicit return used).

There are plenty of useful tools for skimming the cream of CPAN :
* CPAN Ra(n)tings which is already integrated into metacpan
* metacpan recommendation/endorsements (
https://metacpan.org/favorite/leaderboard, not linked from front page,
which is a shame as it's a really nice feature)
* http://cpan-u.sysd.org/ which is an amazon/netflix style recommendation system
* https://www.socialtext.net/perl5/

There is a LOT on CPAN, but it's not about the size, it's about what
you do with it, and the eco-system and tools around it continue to
improve and set the bar higher for similar code repos :)

Cheers,

A

-- 
Aaron J Trevena, BSc Hons
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Consulting


Re: cpan you have to see

2012-12-12 Thread Anthony Lucas

Hahaha. Flexible::Output::Printer version 0.4.5 is a masterpiece.

I think I've found the new does this person know Perl instant test. Take a 
look at this module...



--Original Message--
From: Uri Guttman
Sender: london.pm-boun...@london.pm.org
To: london.pm@london.pm.org
ReplyTo: London.pm Perl M\[ou\]ngers
Subject: cpan you have to see
Sent: 12 Dec 2012 07:29

i can't say much about this but you have to look at the code here.

https://metacpan.org/author/PERLOOK/

in particular the boolean stuff is amazing and the print stuff isn't far 
behind.

uri




Re: cpan you have to see

2012-12-12 Thread Zbigniew Łukasiak
On Wed, Dec 12, 2012 at 9:54 AM, Anthony Lucas anthonyjlu...@gmail.com wrote:

 Hahaha. Flexible::Output::Printer version 0.4.5 is a masterpiece.

 I think I've found the new does this person know Perl instant test. Take a 
 look at this module...

This is mean.





 --Original Message--
 From: Uri Guttman
 Sender: london.pm-boun...@london.pm.org
 To: london.pm@london.pm.org
 ReplyTo: London.pm Perl M\[ou\]ngers
 Subject: cpan you have to see
 Sent: 12 Dec 2012 07:29

 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/

 in particular the boolean stuff is amazing and the print stuff isn't far
 behind.

 uri





--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/


Re: cpan you have to see

2012-12-12 Thread Ian Docherty
Wow, I have learned so much from reading that code!

(nothing about Perl however).




On 12 December 2012 07:29, Uri Guttman u...@stemsystems.com wrote:

 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/**PERLOOK/https://metacpan.org/author/PERLOOK/

 in particular the boolean stuff is amazing and the print stuff isn't far
 behind.

 uri




-- 
Regards
Ian


Re: cpan you have to see

2012-12-12 Thread Peter Sergeant
On Wed, Dec 12, 2012 at 8:54 AM, Anthony Lucas anthonyjlu...@gmail.comwrote:

 Flexible::Output::Printer


To be honest, it's not too different in intent from several other CPAN
modules - aliasing features to be more like other languages...

I am pretty curious about the return values, though:

return bless {};


I wonder what the intent there was...

-P


Re: cpan you have to see

2012-12-12 Thread Anthony Lucas
I wouldn't really say mean…

The examples themselves trigger the module's own ridiculous failure conditions. 
I have a hard time believing these aren't joke modules.

The interesting conversation here is about CPAN moderation and where people 
stand on it.
I know it tends to be extremely liberal, but when it comes to harmful modules 
(if someone comes from another language, doesn't read the source, and starts 
using them), what's the stance?


--  
Anthony Lucas
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Wednesday, 12 December 2012 at 09:19, Peter Sergeant wrote:

 On Wed, Dec 12, 2012 at 8:54 AM, Anthony Lucas anthonyjlu...@gmail.com 
 (mailto:anthonyjlu...@gmail.com) wrote:
  Flexible::Output::Printer
 To be honest, it's not too different in intent from several other CPAN 
 modules - aliasing features to be more like other languages...
  
 I am pretty curious about the return values, though:
  
 return bless {};
  
 I wonder what the intent there was...
  
 -P
  



Re: cpan you have to see

2012-12-12 Thread Avishalom Shalit
no,
this
http://perl.plover.com/IAQ/IAQlist.html#how_can_i_find_the_creation_date_of_a_file

is mean.
:-)

-- vish




On 12 December 2012 09:35, Anthony Lucas anthonyjlu...@gmail.com wrote:

 I wouldn't really say mean…

 The examples themselves trigger the module's own ridiculous failure
 conditions. I have a hard time believing these aren't joke modules.

 The interesting conversation here is about CPAN moderation and where
 people stand on it.
 I know it tends to be extremely liberal, but when it comes to harmful
 modules (if someone comes from another language, doesn't read the source,
 and starts using them), what's the stance?


 --
 Anthony Lucas
 Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


 On Wednesday, 12 December 2012 at 09:19, Peter Sergeant wrote:

  On Wed, Dec 12, 2012 at 8:54 AM, Anthony Lucas 
  anthonyjlu...@gmail.com(mailto:
 anthonyjlu...@gmail.com) wrote:
   Flexible::Output::Printer
  To be honest, it's not too different in intent from several other CPAN
 modules - aliasing features to be more like other languages...
 
  I am pretty curious about the return values, though:
 
  return bless {};
 
  I wonder what the intent there was...
 
  -P
 




Re: cpan you have to see

2012-12-12 Thread Spiros Denaxas
That is plain immature.



On Wed, Dec 12, 2012 at 9:57 AM, Avishalom Shalit avisha...@gmail.comwrote:

 no,
 this

 http://perl.plover.com/IAQ/IAQlist.html#how_can_i_find_the_creation_date_of_a_file

 is mean.
 :-)

 -- vish




 On 12 December 2012 09:35, Anthony Lucas anthonyjlu...@gmail.com wrote:

  I wouldn't really say mean…
 
  The examples themselves trigger the module's own ridiculous failure
  conditions. I have a hard time believing these aren't joke modules.
 
  The interesting conversation here is about CPAN moderation and where
  people stand on it.
  I know it tends to be extremely liberal, but when it comes to harmful
  modules (if someone comes from another language, doesn't read the source,
  and starts using them), what's the stance?
 
 
  --
  Anthony Lucas
  Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
 
 
  On Wednesday, 12 December 2012 at 09:19, Peter Sergeant wrote:
 
   On Wed, Dec 12, 2012 at 8:54 AM, Anthony Lucas 
 anthonyjlu...@gmail.com(mailto:
  anthonyjlu...@gmail.com) wrote:
Flexible::Output::Printer
   To be honest, it's not too different in intent from several other CPAN
  modules - aliasing features to be more like other languages...
  
   I am pretty curious about the return values, though:
  
   return bless {};
  
   I wonder what the intent there was...
  
   -P
  
 
 



Re: cpan you have to see

2012-12-12 Thread Avishalom Shalit
well, it is a page full of jokes.
read it in context.
some of them are actually funny, (in an Asperger's humor sort of funny. )
let me kill the frog*
How do I sort an array in reverse?

@sorted = sort reverse @array;

I really like how the perl mirrors the english, this is exactly
sorting an array in reverse ;  as opposed to reverse sorting an
array.

also i am guilty of a chortle at
http://perl.plover.com/IAQ/IAQlist.html#what%27s_a_regular_expression_to_replace_09:23:53_08oct98_with_thu_oct_8_09:23:53_1998


_
* Mark Twain reference, incidentally, this meta humor explanation is a
second killing.

-- vish




On 12 December 2012 10:14, Spiros Denaxas s.dena...@gmail.com wrote:

 That is plain immature.



 On Wed, Dec 12, 2012 at 9:57 AM, Avishalom Shalit avisha...@gmail.com
 wrote:

  no,
  this
 
 
 http://perl.plover.com/IAQ/IAQlist.html#how_can_i_find_the_creation_date_of_a_file
 
  is mean.
  :-)
 
  -- vish
 
 
 
 
  On 12 December 2012 09:35, Anthony Lucas anthonyjlu...@gmail.com
 wrote:
 
   I wouldn't really say mean…
  
   The examples themselves trigger the module's own ridiculous failure
   conditions. I have a hard time believing these aren't joke modules.
  
   The interesting conversation here is about CPAN moderation and where
   people stand on it.
   I know it tends to be extremely liberal, but when it comes to harmful
   modules (if someone comes from another language, doesn't read the
 source,
   and starts using them), what's the stance?
  
  
   --
   Anthony Lucas
   Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
  
  
   On Wednesday, 12 December 2012 at 09:19, Peter Sergeant wrote:
  
On Wed, Dec 12, 2012 at 8:54 AM, Anthony Lucas 
  anthonyjlu...@gmail.com(mailto:
   anthonyjlu...@gmail.com) wrote:
 Flexible::Output::Printer
To be honest, it's not too different in intent from several other
 CPAN
   modules - aliasing features to be more like other languages...
   
I am pretty curious about the return values, though:
   
return bless {};
   
I wonder what the intent there was...
   
-P
   
  
  
 



Re: cpan you have to see

2012-12-12 Thread Mark Overmeer
* Avishalom Shalit (avisha...@gmail.com) [121212 10:02]:
 this
 http://perl.plover.com/IAQ/IAQlist.html#how_can_i_find_the_creation_date_of_a_file
 
 is mean.
 :-)

hah funny!  In so many ways broken and so dangerous!

I think the problem of the document is that is survives on internet,
while it is a April 1st joke.  Are you aware of April 1st jokes the
whole year?  It reads like Matt's script archieve and code I see every
day in production.

A search engine will bring people to the middle of the page and may make
them produce horrible code.  Maybe there should be a more visible hint
that these are all jokes.
-- 
Regards,

   MarkOv


   Mark Overmeer MScMARKOV Solutions
   m...@overmeer.net  soluti...@overmeer.net
http://Mark.Overmeer.net   http://solutions.overmeer.net



Re: cpan you have to see

2012-12-12 Thread Richard Foley
Mean? I thought he was being remarkably nice!

-- 
Ciao

Richard Foley

http://www.rfi.net/books.html

On Wed, Dec 12, 2012 at 10:03:48AM +0100, Zbigniew Łukasiak wrote:
 On Wed, Dec 12, 2012 at 9:54 AM, Anthony Lucas anthonyjlu...@gmail.com 
 wrote:
 
  Hahaha. Flexible::Output::Printer version 0.4.5 is a masterpiece.
 
  I think I've found the new does this person know Perl instant test. Take 
  a look at this module...
 
 This is mean.
 
 
 
 
 
  --Original Message--
  From: Uri Guttman
  Sender: london.pm-boun...@london.pm.org
  To: london.pm@london.pm.org
  ReplyTo: London.pm Perl M\[ou\]ngers
  Subject: cpan you have to see
  Sent: 12 Dec 2012 07:29
 
  i can't say much about this but you have to look at the code here.
 
  https://metacpan.org/author/PERLOOK/
 
  in particular the boolean stuff is amazing and the print stuff isn't far
  behind.
 
  uri
 
 
 
 
 
 --
 Zbigniew Lukasiak
 http://brudnopis.blogspot.com/
 http://perlalchemy.blogspot.com/


Re: cpan you have to see

2012-12-12 Thread Mark Overmeer
* Avishalom Shalit (avisha...@gmail.com) [121212 11:01]:
 How do I sort an array in reverse?
 @sorted = sort reverse @array;

I do understand the jokes, because I have sufficient knowledge of Perl.
Horrible things get used.

Now guess: is the following a joke or in production code?

   CHECKSHIPPING: {
   last CHECKSHIPPING unless $Vend::Cfg-{TaxShipping};
   foreach $code (@code) {
   next unless $Vend::Cfg-{TaxShipping} =~ /\b\Q$code\E\b/i;
   $amount += tag_shipping();
   last;
   }
   }

-- 
   MarkOv


   Mark Overmeer MScMARKOV Solutions
   m...@overmeer.net  soluti...@overmeer.net
http://Mark.Overmeer.net   http://solutions.overmeer.net



Re: cpan you have to see

2012-12-12 Thread Pedro Figueiredo

On 12 Dec 2012, at 12:12, Leon Brocard a...@astray.com wrote:

 On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:
 i can't say much about this but you have to look at the code here.
 
 https://metacpan.org/author/PERLOOK/
 
 I congratulate Alexej on joining the CPAN authors club. Instead of making fun
 of him on a mailing list why not engage with him and help him improve?

I concur, imagine he picked up a Perl book yesterday and decided to try this 
thing out? And imagine he's signed up for this list, or googles is CPAN 
handle...




Re: cpan you have to see

2012-12-12 Thread Schmoo
On 12 December 2012 12:19, Pedro Figueiredo m...@pedrofigueiredo.org wrote:

 On 12 Dec 2012, at 12:12, Leon Brocard a...@astray.com wrote:

 On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:
 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/

 I congratulate Alexej on joining the CPAN authors club. Instead of making fun
 of him on a mailing list why not engage with him and help him improve?

 I concur, imagine he picked up a Perl book yesterday and decided to try this 
 thing out? And imagine he's signed up for this list, or googles is CPAN 
 handle...



+1


Re: cpan you have to see

2012-12-12 Thread Anthony Lucas
 On 12 Dec 2012, at 12:12, Leon Brocard a...@astray.com wrote:

 I congratulate Alexej on joining the CPAN authors club. Instead of making fun
 of him on a mailing list why not engage with him and help him improve?


No one is really making fun of him. I just don't see the point in
pretending not to be amused. I think everyone saw the direction this
thread could have gone. I just hoped that we were able to honestly
converse about it, instead of shying away from the conversation.
That's also the reason I'm assuming Uri posted it.

Surely there should be interesting conversations about such an
interesting...assortment of modules.

O
n 12 December 2012 12:19, Pedro Figueiredo m...@pedrofigueiredo.org wrote:

 I concur, imagine he picked up a Perl book yesterday and decided to try this 
 thing out? And imagine he's signed up for this list, or googles is CPAN 
 handle...


In case he does read this, please log on to #perl on freenode. I'm
sure there will be many of us willing to help break it down and
explain what is wrong.


Re: cpan you have to see

2012-12-12 Thread Richard Foley
I'm sure Uri's point was meant in jovial (xmas?) spirit, and who's to say it's
not a joke, and how serious do we take all of this, in any case ?-)

On the topic of a CPAN filter: Quis custodiet ipsos custodes?

And, finally, that's a good suggestion, Anthony. I've Cc'd him, (perlook),
here, thinking Alexej might read this mail and investigate further.

-- 
Ciao

Richard Foley

http://www.rfi.net/books.html

On Wed, Dec 12, 2012 at 12:55:12PM +, Anthony Lucas wrote:
  On 12 Dec 2012, at 12:12, Leon Brocard a...@astray.com wrote:
 
  I congratulate Alexej on joining the CPAN authors club. Instead of making 
  fun
  of him on a mailing list why not engage with him and help him improve?
 
 
 No one is really making fun of him. I just don't see the point in
 pretending not to be amused. I think everyone saw the direction this
 thread could have gone. I just hoped that we were able to honestly
 converse about it, instead of shying away from the conversation.
 That's also the reason I'm assuming Uri posted it.
 
 Surely there should be interesting conversations about such an
 interesting...assortment of modules.
 
 O
 n 12 December 2012 12:19, Pedro Figueiredo m...@pedrofigueiredo.org wrote:
 
  I concur, imagine he picked up a Perl book yesterday and decided to try 
  this thing out? And imagine he's signed up for this list, or googles is 
  CPAN handle...
 
 
 In case he does read this, please log on to #perl on freenode. I'm
 sure there will be many of us willing to help break it down and
 explain what is wrong.


Re: cpan you have to see

2012-12-12 Thread Joseph Werner
On Wed, Dec 12, 2012 at 9:17 AM, Joel Bernstein j...@fysh.org wrote:

 I'm more concerned about who keeps the monkeys in their cages from
 flinging their faeces around.

Custodiendam simia cacas!

-- 
Best Regards,
[Joseph] Christian Werner Sr
C 360.920.7183
H 757.304.0502
Txt 757.304.0502


Re: cpan you have to see

2012-12-12 Thread Uri Guttman

On 12/12/2012 07:12 AM, Leon Brocard wrote:

On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:

i can't say much about this but you have to look at the code here.

https://metacpan.org/author/PERLOOK/


I congratulate Alexej on joining the CPAN authors club. Instead of making fun
of him on a mailing list why not engage with him and help him improve?


look at his early rt ticket replies. and i did engage him and admonish 
his attitude. his reply was more normal but he still thinks his code is 
doing something useful and even correct. i will point him in better 
directions later today.


but he should be learning basic perl on his own box and wait for 
publishing until he has something to show. what is up there is very 
broken ('#' is false in his world) and he doesn't know it.


uri



Re: cpan you have to see

2012-12-12 Thread James Laver
On 12 Dec 2012, at 15:57, Uri Guttman u...@stemsystems.com wrote:

 On 12/12/2012 07:12 AM, Leon Brocard wrote:
 he still thinks his code is doing something useful

It is. I had to write something similar to his Boolean module when I inherited 
a fucked up database that had different standards for Boolean values in 
different parts of the code base. Everything was stored in a blob column for 
extra meta-database hate.

Just because you get to work with all of the nice clean code in the world 
doesn't mean some people aren't stuck with the mistakes of others. Then again, 
my primary income stream is writing code and yours is recruitment, so it's 
expected I'm more likely to have to clean up messes.

/j


Re: cpan you have to see

2012-12-12 Thread Alexej Magura
As for my rt replies, what did you expect I was gonna say: 'Oh, my bad I
wrote the worst module in the world and you're the king of all; here let me
just remove it real quick.'?  Think again.

*When I call `true()` I get `undef` back (or empty list in list context).
It should return `i should stop uploading useless modules` instead.*
Is not a valid bug ticket, and it is not remotely funny.  Imagine how all
of you would feel if you had just signed up for Cpan because you thought it
would be neat to be helpful and contribute something to the perl community
only to have the entire community turn on you.  So much for There's more
than one way to do it. (Perl's motto) More like If you don't get it right
the first time, never try again.

Since I joined Cpan, I've only received one bug ticket that was actually
helpful, and I've received four total, to my knowledge.

On Wed, Dec 12, 2012 at 12:05 PM, Alexej Magura perl...@cpan.org wrote:

 Okay, allow me to clarify what the TrueFalse module that I wrote is trying
 to emulate.  It's trying to emulate the 'true' and 'false' user commands
 available under Linux.

 Haven't you ever done something like this in Unix Shell?

 while true; do ls /var/log/; sleep 5s; clear; done

 The statment 'true' in this example, as far as I know, only returns true
 and that's it.  It may not look very useful, but it can be useful when
 you just need to do something and just want to write 'Just because I
 said so, keep doing A until I say stop.'

 I'm sorry if all of you think that my modules are poorly written, but if
 you want me to take you seriously, then say something productive for a
 change, that is make some suggestions (I'm open to suggestions.)



Re: cpan you have to see

2012-12-12 Thread Edmund von der Burg
On 12 December 2012 17:05, Alexej Magura perl...@cpan.org wrote:
 Okay, allow me to clarify what the TrueFalse module that I wrote is trying
 to emulate.  It's trying to emulate the 'true' and 'false' user commands
 available under Linux.

 Haven't you ever done something like this in Unix Shell?

 while true; do ls /var/log/; sleep 5s; clear; done

 The statment 'true' in this example, as far as I know, only returns true
 and that's it.  It may not look very useful, but it can be useful when
 you just need to do something and just want to write 'Just because I
 said so, keep doing A until I say stop.'

 I'm sorry if all of you think that my modules are poorly written, but if
 you want me to take you seriously, then say something productive for a
 change, that is make some suggestions (I'm open to suggestions.)

Each language has its own idioms and ways to do things. In shell
scripting the while true ... done loop is one of them.

In Perl the equivalent would be while (1) {  }

I can understand that you want to make some of the Perl code you write
more familiar by using constructs from other languages. However in
this particular case you are making it more confusing for other
developers. Your use of true or True means that they'll see something
that reads well, but the exact behaviour of that code is not clear.
However using something like '1' is unambiguous - 1 is almost always
used when you need a true value.

I'd suggest bringing across ideas from other languages, but using the
language's own syntax to express them :)

Cheers,
  Edmund.


PS should 'True' not return 1 rather than 0?
https://metacpan.org/source/PERLOOK/Ez-Tf-0.1.2.2/lib/Tf.pm#L74

PPS if you do want to spell out true in your code you could add something like:

use Readonly;
Readonly my $TRUE = 1;



while ( $TRUE ) {
  
}

# This will tell other developers that $TRUE is a variable (as it
starts with a $) and lets them search for it in the same file that the
use is in so they can see its value. It also can't be changed
accidentally as it is readonly (https://metacpan.org/module/Readonly).


Re: cpan you have to see

2012-12-12 Thread ian docherty
Alexej
I was going to ask just one question 'why?', but then I thought back to my
dim and distant past and I remembered doing something very similar.

I was learning programming language 'B' after being fairly proficient (as I
thought at the time) in language 'A'.

I started writing macros and routines in 'B' to make it look more like 'A'.

Instead I should have embraced language 'B', written my code in the
'approved' style rather than a bastardised version trying to emulate
another.

It turned out it was neither cool, useful or sensible. It stopped me
embracing the new language, my code was unreadable both by anyone who knew
'A' or 'B' and was unmaintainable.

I suggest that you forget this approach, I can't see it helping anyone
(especially yourself). There are many ways to do what you want in Perl,
here are just a couple.

while(1) {
# do something
sleep 5;
last if $all_done;
}

my $working = 1;
while ($working) {
# do something
sleep 5;
$working = 0 if $all_done;
}

And numerous variations.


On 12 December 2012 17:05, Alexej Magura perl...@cpan.org wrote:

 Okay, allow me to clarify what the TrueFalse module that I wrote is trying
 to emulate.  It's trying to emulate the 'true' and 'false' user commands
 available under Linux.

 Haven't you ever done something like this in Unix Shell?

 while true; do ls /var/log/; sleep 5s; clear; done

 The statment 'true' in this example, as far as I know, only returns true
 and that's it.  It may not look very useful, but it can be useful when
 you just need to do something and just want to write 'Just because I
 said so, keep doing A until I say stop.'

 I'm sorry if all of you think that my modules are poorly written, but if
 you want me to take you seriously, then say something productive for a
 change, that is make some suggestions (I'm open to suggestions.)



Re: cpan you have to see

2012-12-12 Thread Anthony Lucas

Hop on to IRC sometime and discuss it. RT is not the right place for this kind 
of thing anyway.

-Original Message-
From: Alexej Magura perl...@cpan.org
Sender: london.pm-boun...@london.pm.org
Date: Wed, 12 Dec 2012 12:21:13 
To: London.pm Perl M[ou]ngerslondon.pm@london.pm.org
Reply-To: London.pm Perl M\[ou\]ngers london.pm@london.pm.org
Subject: Re: cpan you have to see

As for my rt replies, what did you expect I was gonna say: 'Oh, my bad I
wrote the worst module in the world and you're the king of all; here let me
just remove it real quick.'?  Think again.

*When I call `true()` I get `undef` back (or empty list in list context).
It should return `i should stop uploading useless modules` instead.*
Is not a valid bug ticket, and it is not remotely funny.  Imagine how all
of you would feel if you had just signed up for Cpan because you thought it
would be neat to be helpful and contribute something to the perl community
only to have the entire community turn on you.  So much for There's more
than one way to do it. (Perl's motto) More like If you don't get it right
the first time, never try again.

Since I joined Cpan, I've only received one bug ticket that was actually
helpful, and I've received four total, to my knowledge.

On Wed, Dec 12, 2012 at 12:05 PM, Alexej Magura perl...@cpan.org wrote:

 Okay, allow me to clarify what the TrueFalse module that I wrote is trying
 to emulate.  It's trying to emulate the 'true' and 'false' user commands
 available under Linux.

 Haven't you ever done something like this in Unix Shell?

 while true; do ls /var/log/; sleep 5s; clear; done

 The statment 'true' in this example, as far as I know, only returns true
 and that's it.  It may not look very useful, but it can be useful when
 you just need to do something and just want to write 'Just because I
 said so, keep doing A until I say stop.'

 I'm sorry if all of you think that my modules are poorly written, but if
 you want me to take you seriously, then say something productive for a
 change, that is make some suggestions (I'm open to suggestions.)




Re: cpan you have to see

2012-12-12 Thread Guinevere Nell
I disagree - using $TRUE is fine! Perl was my first language and it makes
perfect sense to me.

More importantly: it seems the Perl community has lost it's warmth and
communal, welcoming, nature - maybe since it's a falling empire, people
have gotten rude and boorish? I don't know, but I am disappointed with the
way the list members are acting--I am not surprised that Perl is getting
few converts these days if this is how newcomers to the Perl community are
treated.

On Wed, Dec 12, 2012 at 5:23 PM, Edmund von der Burg
e...@ecclestoad.co.ukwrote:

 On 12 December 2012 17:05, Alexej Magura perl...@cpan.org wrote:
  Okay, allow me to clarify what the TrueFalse module that I wrote is
 trying
  to emulate.  It's trying to emulate the 'true' and 'false' user commands
  available under Linux.
 
  Haven't you ever done something like this in Unix Shell?
 
  while true; do ls /var/log/; sleep 5s; clear; done
 
  The statment 'true' in this example, as far as I know, only returns true
  and that's it.  It may not look very useful, but it can be useful when
  you just need to do something and just want to write 'Just because I
  said so, keep doing A until I say stop.'
 
  I'm sorry if all of you think that my modules are poorly written, but if
  you want me to take you seriously, then say something productive for a
  change, that is make some suggestions (I'm open to suggestions.)

 Each language has its own idioms and ways to do things. In shell
 scripting the while true ... done loop is one of them.

 In Perl the equivalent would be while (1) {  }

 I can understand that you want to make some of the Perl code you write
 more familiar by using constructs from other languages. However in
 this particular case you are making it more confusing for other
 developers. Your use of true or True means that they'll see something
 that reads well, but the exact behaviour of that code is not clear.
 However using something like '1' is unambiguous - 1 is almost always
 used when you need a true value.

 I'd suggest bringing across ideas from other languages, but using the
 language's own syntax to express them :)

 Cheers,
   Edmund.


 PS should 'True' not return 1 rather than 0?
 https://metacpan.org/source/PERLOOK/Ez-Tf-0.1.2.2/lib/Tf.pm#L74

 PPS if you do want to spell out true in your code you could add something
 like:

 use Readonly;
 Readonly my $TRUE = 1;

 

 while ( $TRUE ) {
   
 }

 # This will tell other developers that $TRUE is a variable (as it
 starts with a $) and lets them search for it in the same file that the
 use is in so they can see its value. It also can't be changed
 accidentally as it is readonly (https://metacpan.org/module/Readonly).




-- 
http://economicliberty.net/


Re: cpan you have to see

2012-12-12 Thread Mark Fowler
On Wednesday, 12 December 2012 at 12:21, Alexej Magura wrote:
 Since I joined Cpan, I've only received one bug ticket that was actually
 helpful, and I've received four total, to my knowledge.

Alexj, I am sorry to hear that.  I just wanted to say, on behalf of the often 
silent majority, we appreciate all the effort that people put into their Perl 
modules on the CPAN.  It, as you have just pointed out, can be a thankless 
task.  So thank you.

Mark.




Re: cpan you have to see

2012-12-12 Thread Gareth Harper
On 12 December 2012 17:05, Alexej Magura perl...@cpan.org wrote:
 Okay, allow me to clarify what the TrueFalse module that I wrote is trying
 to emulate.  It's trying to emulate the 'true' and 'false' user commands
 available under Linux.

 Haven't you ever done something like this in Unix Shell?

 while true; do ls /var/log/; sleep 5s; clear; done

 The statment 'true' in this example, as far as I know, only returns true
 and that's it.  It may not look very useful, but it can be useful when
 you just need to do something and just want to write 'Just because I
 said so, keep doing A until I say stop.'

 I'm sorry if all of you think that my modules are poorly written, but if
 you want me to take you seriously, then say something productive for a
 change, that is make some suggestions (I'm open to suggestions.)


Without commenting on the function of the modules (I personally
wouldn't use them, but I can see what you're trying to accomplish).
Style/function/speed wise there certainly are a few areas which you
may want to address.  I'll explain some of the more obvious ones here,
though there are several other things you may want to look at.  I see
several other people have volunteered help as well.

First, you will probably want to look at strict.  This will turn
strict mode on in Perl which will flag up possible problems in your
code (such as undeclared variables) and many other issues.  You can
read more here

Also there appears to be a lot of copied and pasted code inbetween
your modules, you should try to have one library providing the
function and then simply use that library in the places you need to
use it.

http://perldoc.perl.org/strict.html

Traditionally most CPAN modules come with a test suite which allows
both the author and anyone using the libraries to ensure they are
working correctly.  It also means if there are bugs found, then you
can simply create a test case to prove the bug, then fix it and be
sure it will never return.  There are many different libraries you
could use to accomplish this, but I find this one easy to use (it even
comes with Perl as standard).

http://search.cpan.org/~mschwern/Test-Simple-0.98/lib/Test/More.pm

If you create your module framework with something like the module
below (there are several other options), then you will have the entire
module skeleton laid out for you (including a basic test suite, and
all the documentation/MANIFEST files) and you simply need to add the
test cases and the code (and edit the documentation files).

http://search.cpan.org/~jkeenan/ExtUtils-ModuleMaker-0.51/lib/ExtUtils/ModuleMaker.pm


Looking at the modules individually:

https://metacpan.org/source/PERLOOK/Flexible-Output-Printer-0.4.5/lib/Printer.pm#PFlexible%3A%3AOutput%3A%3APrinter

All of these functions return a blessed anonymous empty hash.  In Perl
bless is used for object oriented programming, to link a particular
variable to a particular package, there is no reason in your modules
to use bless at all.  You can read more about bless here.

http://perldoc.perl.org/functions/bless.html

If your intent was to return a true value (which in this case, you
have done), then you can simply return 1;.


https://metacpan.org/source/PERLOOK/Ez-Tf-0.1.2.2/lib/Tf.pm#PEz%3A%3ATf

Your True function here actually returns 0, which in Perl is treat
as false (undefined, empty string and 0 are the various false values),
you probably want to return 1 here.

Likewise your False and false functions simple return.  Now this will
be treat as false, however it would probably be better to return 0;
such that anyone using your code doesn't get undefined values errors.

Your true function has a return 'True', which IS a true value,
however I suspect you meant to call your True function, so you should
simply return True.

As a sidepoint, having functions named the same, differing only in
case, but doing different things is generally frowned upon, it makes
code using them harder to read and easier to make mistakes in.



https://metacpan.org/source/PERLOOK/Ez-Printer-0.0.3.1/lib/Printer.pm#PEz%3A%3APrinter


Your putc function will exit any program that uses it, if you really
were wanting to throw a critical error, you should use the die
command, however the normal method would be to simple return 0 (or
false).  You could also look into using Error
(http://search.cpan.org/~shlomif/Error-0.17019/lib/Error.pm) to add
exceptions and error throwing.

Thanks

Gareth


Re: cpan you have to see

2012-12-12 Thread Gareth Harper
On 12 December 2012 17:57, Joseph Werner telco...@gmail.com wrote:
 On Wed, Dec 12, 2012 at 12:45 PM, Gareth Harper spansh+lon...@gmail.com 
 wrote:

 PBP and I disagree with you on this one, Gareth. When a sub does a
 return 0; to a list context, that is interpreted as true.  A bare
 return; is best practice.


I stand corrected.


Re: cpan you have to see

2012-12-12 Thread Schmoo
On 12 December 2012 15:57, Uri Guttman u...@stemsystems.com wrote:
 On 12/12/2012 07:12 AM, Leon Brocard wrote:

 On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:

 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/


 I congratulate Alexej on joining the CPAN authors club. Instead of making
 fun
 of him on a mailing list why not engage with him and help him improve?


 look at his early rt ticket replies. and i did engage him and admonish his
 attitude. his reply was more normal but he still thinks his code is doing
 something useful and even correct. i will point him in better directions
 later today.

 but he should be learning basic perl on his own box and wait for publishing
 until he has something to show. what is up there is very broken ('#' is
 false in his world) and he doesn't know it.

How does one know when one 'has something to show'?


Gaz


Re: cpan you have to see

2012-12-12 Thread Yitzchak Scott-Thoennes
On Wed, Dec 12, 2012 at 9:23 AM, Edmund von der Burg
e...@ecclestoad.co.uk wrote:
 Each language has its own idioms and ways to do things. In shell
 scripting the while true ... done loop is one of them.

 In Perl the equivalent would be while (1) {  }

Actually, it's:  while () { ... }

But not many people seem to remember that.  :)

Programming Perl has this to say:
 Speakers of a natural language are allowed to have differing skill levels, to 
 speak different subsets of the language, to learn as they go, and, generally, 
 to put the language to good use before they know the whole language.  You 
 don't know all of Perl yet, just as you don't know all of English.  But 
 that's Officially Okay in Perl culture.  You can work with Perl usefully, 
 even though we haven't even told you how to write your own subroutines yet.

And, yes, I think that applies even to code published on CPAN.
If there are *bugs*, report them.



Re: cpan you have to see

2012-12-12 Thread Abigail
On Wed, Dec 12, 2012 at 10:57:39AM -0500, Uri Guttman wrote:
 On 12/12/2012 07:12 AM, Leon Brocard wrote:
 On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:
 i can't say much about this but you have to look at the code here.

 https://metacpan.org/author/PERLOOK/

 I congratulate Alexej on joining the CPAN authors club. Instead of making fun
 of him on a mailing list why not engage with him and help him improve?

 look at his early rt ticket replies. and i did engage him and admonish  
 his attitude. his reply was more normal but he still thinks his code is  
 doing something useful and even correct. i will point him in better  
 directions later today.

 but he should be learning basic perl on his own box and wait for  
 publishing until he has something to show. what is up there is very  
 broken ('#' is false in his world) and he doesn't know it.


The power of CPAN is that it is available to *ALL*.

Noone is forcing you to use what's there. If you think it's crappy, don't
use it. If it pisses you off people prefer to use a module that you think
is crappy, write something better. After all, most people just want to 
fix a problem, and they don't (usually rightly) how it's solved.

If only code that is approved by a cabal is allowed on CPAN, it will
quickly become something else then it's now. 



Abigail


Re: cpan you have to see

2012-12-12 Thread Peter Sergeant
On Wed, Dec 12, 2012 at 6:14 PM, Gareth Harper spansh+lon...@gmail.comwrote:

 On 12 December 2012 17:57, Joseph Werner telco...@gmail.com wrote:
  On Wed, Dec 12, 2012 at 12:45 PM, Gareth Harper spansh+lon...@gmail.com
 wrote:
 
  PBP and I disagree with you on this one, Gareth. When a sub does a
  return 0; to a list context, that is interpreted as true.  A bare
  return; is best practice.
 

 I stand corrected.


Don't stand corrected too quickly - the idea that you should always use a
bare *return()* is far from universally accepted - you can bite yourself
just as easily in reverse by using bare return, and getting an empty list
where you expected a false or undefined value:

https://gist.github.com/4270506

The boolean argument is reaching, at best. Perl programmers frequently use
numeric 0 as a false value, and yet no-one is saying you should write code
like:

sub lock_count {
if ( $lock_counter ) {
 return $lock_counter;
} else {
 return;
}
}

Just in case someone has decided to take your input in to an array,
before asking if lock_count is true.

If you're using a bare return then all your returns should be
*wantarray*dependent, or you're making the code even less predictable
- making the
*return* of an undefined value the only context-dependent *return* in a sub
is crazy talk!

The simple rule here is: write functions that return either a list, or a
scalar, and not both, and be explicit in your function documentation which
you're expecting to return.

-P


Re: cpan you have to see

2012-12-12 Thread Hakim Cassimally
Hi Alex,

I'm sorry that you've had a bad initial experience of CPAN and now of
this mailing list.

On 12 December 2012 17:21, Alexej Magura perl...@cpan.org wrote:
 As for my rt replies, what did you expect I was gonna say: 'Oh, my bad I
 wrote the worst module in the world and you're the king of all; here let me
 just remove it real quick.'?  Think again.

The RT commenter who wrote:

This isn't python's pypi where everybody is encouraged to upload for
fun whether useful or not. Only upload something if it will be useful
to others.

is entirely wrong.  CPAN flourishes not despite the fact because we
accept all code, regardless of quality, but *because* of it.

Though it looks like your CPAN code has a few rough edges, many of
them can be resolved quite straight-forwardly, and I see you've
already had some helpful advice on how to do that from Edmund, Gareth
et al.

Best,
Hakim


Re: cpan you have to see

2012-12-12 Thread Lyle
It seems this guy is sticking up for himself following the regular LPM 
taunts. Shouldn't most of you now follow up with more nastiness, some 
insults in ASCII art, then when he gives anything back kick him from the 
list? As far as I've experienced, this is how you do things.


After all, only the cabal should be really be coding Perl. Anyone new to 
Perl should be an instant expert, or at the very least, bend over and 
hand the lube to the nearest cabeller.


Then later you should have some threads on why more new people aren't 
coming to Perl and this community, and how you can't really understand 
why they wouldn't.



Lyle

On 12/12/2012 17:21, Alexej Magura wrote:

As for my rt replies, what did you expect I was gonna say: 'Oh, my bad I
wrote the worst module in the world and you're the king of all; here let me
just remove it real quick.'?  Think again.

*When I call `true()` I get `undef` back (or empty list in list context).
It should return `i should stop uploading useless modules` instead.*
Is not a valid bug ticket, and it is not remotely funny.  Imagine how all
of you would feel if you had just signed up for Cpan because you thought it
would be neat to be helpful and contribute something to the perl community
only to have the entire community turn on you.  So much for There's more
than one way to do it. (Perl's motto) More like If you don't get it right
the first time, never try again.

Since I joined Cpan, I've only received one bug ticket that was actually
helpful, and I've received four total, to my knowledge.

On Wed, Dec 12, 2012 at 12:05 PM, Alexej Magura perl...@cpan.org wrote:


Okay, allow me to clarify what the TrueFalse module that I wrote is trying
to emulate.  It's trying to emulate the 'true' and 'false' user commands
available under Linux.

Haven't you ever done something like this in Unix Shell?

while true; do ls /var/log/; sleep 5s; clear; done

The statment 'true' in this example, as far as I know, only returns true
and that's it.  It may not look very useful, but it can be useful when
you just need to do something and just want to write 'Just because I
said so, keep doing A until I say stop.'

I'm sorry if all of you think that my modules are poorly written, but if
you want me to take you seriously, then say something productive for a
change, that is make some suggestions (I'm open to suggestions.)





Re: cpan you have to see

2012-12-12 Thread Tom Hukins
On Wed, Dec 12, 2012 at 08:02:28PM +, Lyle wrote:
 It seems this guy is sticking up for himself following the regular LPM 
 taunts. Shouldn't most of you now follow up with more nastiness, some 
 insults in ASCII art, then when he gives anything back kick him from the 
 list? As far as I've experienced, this is how you do things.

Lyle, you posted a rude, unconstructive message.  Your rudeness
contrasts with the polite, helpful replies that London.pm members
have written to Alexej.

If you can't behave reasonably on this list, please take your
delusional conspiracy theories elsewhere.

Tom


Re: cpan you have to see

2012-12-12 Thread Uri Guttman

On 12/12/2012 11:46 AM, James Laver wrote:

On 12 Dec 2012, at 15:57, Uri Guttman u...@stemsystems.com wrote:


On 12/12/2012 07:12 AM, Leon Brocard wrote:

he still thinks his code is doing something useful


It is. I had to write something similar to his Boolean module when I
inherited a fucked up database that had different standards for
Boolean values in different parts of the code base. Everything was
stored in a blob column for extra meta-database hate.

Just because you get to work with all of the nice clean code in the
world doesn't mean some people aren't stuck with the mistakes of
others. Then again, my primary income stream is writing code and
yours is recruitment, so it's expected I'm more likely to have to
clean up messes.


you still have strange views of my career. i have worked with some of 
the ugliest code and team(mis)work in existence. i have recently been 
doing perl support of a team where explaining why globals are bad took a 
few weeks to sink in to one member. you already made a judgment of my 
perl hunting and now another on my main income. i also get royalties 
from o'reilly for stuff. i have more pans in the fire than you would 
imagine. the reason my perl hunting is so good is BECAUSE of my activity 
in perl development, support, training, writing, etc. i can speak perl 
to both sides and do a proper match and never need buzzwords or similar 
fluff.


uri



boolean return (was Re: cpan you have to see)

2012-12-12 Thread Uri Guttman

On 12/12/2012 12:57 PM, Joseph Werner wrote:

On Wed, Dec 12, 2012 at 12:45 PM, Gareth Harper spansh+lon...@gmail.com wrote:

PBP and I disagree with you on this one, Gareth. When a sub does a
return 0; to a list context, that is interpreted as true.  A bare
return; is best practice.


and i support that as well. the argument i get from the other side is 
when calling foo() in a list context that needs a scalar like a hash value:


sub foo { ... return if $bad }
%bar = ( foo = foo() ) ;# fail

my counter answer is to use scalar there:

%bar = ( foo = scalar foo() ) ;

the win here is letting the caller decide on the context of the boolean 
return. if you do a return undef (or 0 or '') then the caller can't ever 
use the sub in a list context expecting an empty list, it always gets a 
scalar. a plain return works in all contexts and lets the caller force a 
scalar when needed.


uri


Re: cpan you have to see

2012-12-12 Thread Tom Hukins
On Wed, Dec 12, 2012 at 04:05:58PM -0500, Uri Guttman wrote:
 On 12/12/2012 11:46 AM, James Laver wrote:
  Just because you get to work with all of the nice clean code in the
  world doesn't mean some people aren't stuck with the mistakes of
  others. Then again, my primary income stream is writing code and
  yours is recruitment, so it's expected I'm more likely to have to
  clean up messes.
 
 you still have strange views of my career. i have worked with some of 
 the ugliest code and team(mis)work in existence.

I asked you both not to bicker on the list last week, yet you're at it
again.

I have temporarily set both of your subscriptions to moderated mode,
along with Lyle's.  The moderators will approve any interesting posts
that you write.

Tom (London.pm leader)


Re: cpan you have to see

2012-12-12 Thread Aaron Crane
Peter Sergeant p...@clueball.com wrote:
 the idea that you should always use a
 bare *return()* is far from universally accepted - you can bite yourself
 just as easily in reverse by using bare return, and getting an empty list
 where you expected a false or undefined value:

I agree.  The talk I did at LPW and YAPC::EU this year covers this and
some related issues:

http://aaroncrane.co.uk/talks/calamitous_context/

-- 
Aaron Crane ** http://aaroncrane.co.uk/


Re: boolean return (was Re: cpan you have to see)

2012-12-12 Thread Abigail
On Wed, Dec 12, 2012 at 04:17:28PM -0500, Uri Guttman wrote:
 On 12/12/2012 12:57 PM, Joseph Werner wrote:
 On Wed, Dec 12, 2012 at 12:45 PM, Gareth Harper spansh+lon...@gmail.com 
 wrote:

 PBP and I disagree with you on this one, Gareth. When a sub does a
 return 0; to a list context, that is interpreted as true.  A bare
 return; is best practice.

 and i support that as well. the argument i get from the other side is  
 when calling foo() in a list context that needs a scalar like a hash 
 value:

   sub foo { ... return if $bad }
   %bar = ( foo = foo() ) ;   # fail

 my counter answer is to use scalar there:

   %bar = ( foo = scalar foo() ) ;

 the win here is letting the caller decide on the context of the boolean  
 return. if you do a return undef (or 0 or '') then the caller can't ever  
 use the sub in a list context expecting an empty list, it always gets a  
 scalar. a plain return works in all contexts and lets the caller force a  
 scalar when needed.



The flip side of this dogma is, you end up with code like:

sub foo {
...
return unless $result;
return $result;
}

with people calling it like:

my @foo = (scalar foo (1), scalar foo (2));

just in case someone at sometime wants to call this in list context
and then have an empty list.


That's a price I'm not willing to pay. Foreach function, I will make
a pragmatic choice, in some cases a plain return is the way to go,
and sometime it isn't.

Dogmas are useful for novices; and people following dogmas will have
a hard time to get past me if they get interviewed by me.



Abigail


Re: boolean return (was Re: cpan you have to see)

2012-12-12 Thread Peter Sergeant
On Wed, Dec 12, 2012 at 9:17 PM, Uri Guttman u...@stemsystems.com wrote:

 then the caller can't ever use the sub in a list context expecting an
 empty list


... so?

True or false are reasonable things to expect a subroutine to return. A
list is a reasonable thing to expect a subroutine to return. True, false,
or SURPRISE! a zero-length list! does not seem like a reasonable return
value.

I suspect that with some work, we could generate a real-world example where
a user might want a true value, OR (a false value OR an empty list). But if
that's really, really what the caller wants, they can easily stick a grep
in front of the call to the sub and get that.

-P


Re: boolean return (was Re: cpan you have to see)

2012-12-12 Thread DAVID HODGKINSON

On 12 Dec 2012, at 21:17, Uri Guttman u...@stemsystems.com wrote:

 On 12/12/2012 12:57 PM, Joseph Werner wrote:
 On Wed, Dec 12, 2012 at 12:45 PM, Gareth Harper spansh+lon...@gmail.com 
 wrote:
 
 PBP and I disagree with you on this one, Gareth. When a sub does a
 return 0; to a list context, that is interpreted as true.  A bare
 return; is best practice.
 
 and i support that as well. the argument i get from the other side is when 
 calling foo() in a list context that needs a scalar like a hash value:
 
   sub foo { ... return if $bad }
   %bar = ( foo = foo() ) ;   # fail
 
 my counter answer is to use scalar there:
 
   %bar = ( foo = scalar foo() ) ;
 
 the win here is letting the caller decide on the context of the boolean 
 return. if you do a return undef (or 0 or '') then the caller can't ever use 
 the sub in a list context expecting an empty list, it always gets a scalar. a 
 plain return works in all contexts and lets the caller force a scalar when 
 needed.

Coming from a strongly-typed background (C, C++), this bisexuality
of returns seems error prone to me. My gut instinct is to have two 
subs, if necessary with one _as_scalar and one _as_hash. Clear, separate
and less open to errors like these.

Am I missing some kind of magic here?





Re: cpan you have to see

2012-12-12 Thread Peter Sergeant
On Wed, Dec 12, 2012 at 9:31 PM, Aaron Crane p...@aaroncrane.co.uk wrote:

 I agree.  The talk I did at LPW and YAPC::EU this year covers this and
 some related issues


Thanks Aaron. Someone told me about your talk, and it got me thinking about
it in-depth a little while ago. Shame I missed it

-P


Re: cpan you have to see

2012-12-12 Thread DAVID HODGKINSON

On 12 Dec 2012, at 18:35, Abigail abig...@abigail.be wrote:

 On Wed, Dec 12, 2012 at 10:57:39AM -0500, Uri Guttman wrote:
 On 12/12/2012 07:12 AM, Leon Brocard wrote:
 On Wed, Dec 12, 2012 at 02:29:24AM -0500, Uri Guttman wrote:
 i can't say much about this but you have to look at the code here.
 
 https://metacpan.org/author/PERLOOK/
 
 I congratulate Alexej on joining the CPAN authors club. Instead of making 
 fun
 of him on a mailing list why not engage with him and help him improve?
 
 look at his early rt ticket replies. and i did engage him and admonish  
 his attitude. his reply was more normal but he still thinks his code is  
 doing something useful and even correct. i will point him in better  
 directions later today.
 
 but he should be learning basic perl on his own box and wait for  
 publishing until he has something to show. what is up there is very  
 broken ('#' is false in his world) and he doesn't know it.
 
 
 The power of CPAN is that it is available to *ALL*.
 
 Noone is forcing you to use what's there. If you think it's crappy, don't
 use it. If it pisses you off people prefer to use a module that you think
 is crappy, write something better. After all, most people just want to 
 fix a problem, and they don't (usually rightly) how it's solved.
 
 If only code that is approved by a cabal is allowed on CPAN, it will
 quickly become something else then it's now. 

Do we still have automated kwalitee on CPAN? 

Would hurling a PBP test at the whole of CPAN to get a metric be of any benefit?






Re: boolean return (was Re: cpan you have to see)

2012-12-12 Thread Mark Overmeer
* Abigail (abig...@abigail.be) [121212 21:38]:
 The flip side of this dogma is, you end up with code like:
 
 sub foo {
 ...
 return unless $result;
 return $result;
 }

  sub foo {
  ...
  $result || ();   # $result // ();
  }

Suitable for list-filters only.
-- 
   MarkOv


   Mark Overmeer MScMARKOV Solutions
   m...@overmeer.net  soluti...@overmeer.net
http://Mark.Overmeer.net   http://solutions.overmeer.net



Re: cpan you have to see

2012-12-12 Thread Peter Sergeant
On Wednesday, December 12, 2012, DAVID HODGKINSON wrote:


 Would hurling a PBP test at the whole of CPAN to get a metric be of any
 benefit?


Probably not. perl critic, which sounds like what you're thinking about, is
a useful tool for catching silly mistakes you might have made, but if you
know what you're doing then many of the things it considers errors are
actually reasonable.

I've worked in a couple of places that run perl critic over the codebase as
part of automated testing, and it's been useful. Invariably though
situations arise where you break one of its rules and switch it off for
that line of code.

Unless someone has written their code with it, and explicitly marked where
they know better, their code is liable to be penalised by a perl critic
scorer. Additionally the score will reflect the small stuff and not
quality of interface, design, documentation, etc, leading to dreadful code
with a perfect score, and excellent code with a terrible score


Re: cpan you have to see

2012-12-12 Thread Mark Keating

On 12/12/2012 21:42, Peter Sergeant wrote:

On Wed, Dec 12, 2012 at 9:31 PM, Aaron Crane p...@aaroncrane.co.uk wrote:


I agree.  The talk I did at LPW and YAPC::EU this year covers this and
some related issues


Thanks Aaron. Someone told me about your talk, and it got me thinking about
it in-depth a little while ago. Shame I missed it

-P

It's on You Tube:

http://www.youtube.com/watch?v=NbP0AtEaxBU

I uploaded it today :)

--
Mark Keating BA (Hons), Writer, Photographer, Cat-Herder.
Managing Director: http://www.shadow.cat
For more that I do visit: http://www.mdk.me