user-pic

mascip

  • About: Interested in languages. I like clean, concise, self-explanatory code - with comments too. I like to think "How to best express...?"
  • Commented on Indented comments
    PS: like educated_foo, i use comments only to express the purpose of the paragraph. Not implementation details. Reading only the comments, you should understand what my code does....
  • Commented on Indented comments
    Since i read Perl Best Practices (pages 23 and 142), i write code in paragraphs, with a short one-line comment before each paragraph. I find it really useful. I keep most paragraphs under 5 lines, and most methods under 5...
  • Commented on Augment and Inner: Haters Gotta Hate
    I like the first example: in a hierarchy that already exists, that's a great way to avoid duplication. The second example could be implemented with a Role: you would require the actions() method, and build a common behavior "around()" it....
  • Commented on The clearest way(s) to check if a List contains...
    What do you mean "all variant is bad"? Do you know Perl's TIMTOWTDI motto? http://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it (the examples on this page suck...i might go and propose something better later). And (as NOT written in this wikipedia page unfortunately) TIMTOWDI does not...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Hey Nick. Ruby has methods who take a block as an argument. An example here with the Tree class (search for "Tree" in the page): http://nickknowlson.com/blog/2011/12/04/seven-languages-week-1-day-2/ The result is : a_tree.visit_all { |node| do_something_with(node) } which will perform an operation...
  • Commented on The clearest way(s) to check if a List contains...
    Yep, i would also prefer 'in' over '~~'...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Thanks for your comments Nick :-) Indeed, these bare blocks after a method call are disconcerting. I didn't even notice that. I guess that's why I compensated by putting them on distinct line: it's the only way i could make...
  • Commented on Improved autobox-ing. I'm loving it :o)
    My purpose here is both to share information and to learn. I said "hey, that's possible! Isn't that cool?", and then i listened. Some people said that they didn't like this syntax but they didn't explain why. I tried to...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Aristotle, I agree with most of what you are saying. However, I think that using the same symbol (the * symbol) in the same block to express two very different things, is confusing. I am referring to this 'map': (^10).map(*...
  • Commented on Improved autobox-ing. I'm loving it :o)
    ARG! Unfortunately PerlX::MethodCallWithBlock seems to have a nasty bug: when i have a compilation error, it changes the line indicated for this error (for example, it will tell me that an error is on line 8, while it's on line...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Do you feel that @list->map { do_something_with($_) } is less clear than map { do_something_with($_) } @list ? If so, is it only because you are more used to it, or are there any other reason? In terms of clarity...
  • Commented on Improved autobox-ing. I'm loving it :o)
    **to which extent would you allow yourself to use useful but new/unusual idioms** in code that you will not be the only one to read/write ? (for example for a CPAN module that you want other people to use) Would...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Ron, do you have examples of when autobox is useful? I'm not trying to prove you wrong or anything; just to learn more about good practices. One more thought about these constructs ( ->map, ->grep ) : Naively, i would...
  • Commented on Improved autobox-ing. I'm loving it :o)
    I managed t answer to Nick, but i don't manage to answer to Ron. It says "Your comment has been received and held for approval by the blog owner." I thought i was the blog owner?...
  • Commented on Improved autobox-ing. I'm loving it :o)
    Surprisingly Nick, i don't like this Perl6 solution very much. I find it not clear; cryptic. (^10) is not as self-explanatory as (1..10) I like self-explanatory code: if i don't have to think or to remember, to understand the code,...
  • Commented on The clearest way(s) to check if a List contains...
    any {$_ eq 'flour'} @ingredients is faster than grep: no need to loop through the whole list. Sligthly modifying this blog post again......
  • Commented on The clearest way(s) to check if a List contains...
    Indeed (c) Thank you....
  • Commented on The clearest way(s) to check if a List contains...
    Why not grep {'flour'} then? It's a bit less ceremony. Someone here says that Smart match is not broken anymore since 5.12....
  • Commented on The clearest way(s) to check if a List contains...
    Writing this article forces me to look into stuff, research, and think about it over and over again. I'm learnings lots and the article has been modified a lot since i released it. If you want to learn Perl, write...
  • Posted Improved autobox-ing. I'm loving it :o) to mascip
    print (0..9)->grep { $_ > 5 }
                ->join(' - ');
    
     # prints: 12 - 14 - 16 - 18
    

    Isn’t that nice ? It is now possible with

    use autobox::Core;    
    use PerlX::Metho…
  • Commented on The clearest way(s) to check if a List contains...
    PS: i now added the ~~ operator to the blog post....
  • Commented on The clearest way(s) to check if a List contains...
    I forgot this one, indeed! Thank you :-) It's a very good one for those who like it. I prefer being more verbose, but that's very personal....
  • Posted The clearest way(s) to check if a List contains... to mascip

    There is more than one way to do it.Toby Inkster’s Creating your own Perl hits the nail on the head: with Perl you can choose the language that you code in

    "So go on; create your own Perl. Make i…
  • Commented on PDL 2.006 released!
    Hi and thanks a lot to the team! I’ve used Matlab for a few years at work, and am quite excited about PDL which seems a lot more versatile, thanks to its Perl foundations. One question from a PDL beginner:...
  • Commented on Better late than never - Perl School is awesome!
    I found the class really excellent and would recommend it to anybody wanting to start using DBIx::Class, or to improve their use of it. If you manipulate databases or plan to, and don't know what DBIx::Class is, then you should...
  • Commented on Documentation for Fun and Profit
    I must say, Pod::HTML::Browser misses some documentation (i struggled a bit to set it up); but the result is nice. And i don't even have it all : i didn't find the favicon and touch icons images anywhere in /img....
  • Commented on Documentation for Fun and Profit
    I have found this talk very good at LPW2012, thank you LoonyPandora. I have gained from listening to this talk : - A refreshing reminder of what a good documentation is and why is really matters. - Several ways to...
Subscribe to feed Recent Actions from mascip

  • Nick Patch commented on Improved autobox-ing. I'm loving it :o)

    You said that “(^10) is not as self-explanatory”.

    It’s not without understanding the fundamentals of Perl 6, like the operators, which are needed in order to program in the language or understand the code. Just like Perl 5 or Ruby has their own prerequisite fundamentals.

    $a  ..  $b  # $a (inclusive) through $b (inclusive)
    $a  ..^ $b  # $a (inclusive) through $b (exclusive)
    $a ^..  $b  # $a (exclusive) through $b (inclusive)
    $a ^..^ $b  # $a (exclusive) through $b (exclusive)
           ^$b  # 0  (inclusive) through $b (exclusive)

    Which makes th…

  • Alexey Shrub commented on The clearest way(s) to check if a List contains...

    All variant is bad, good variant is:
    do_something if 'flour' in @ingredients
    but I don't now how make it

  • chimerix commented on The clearest way(s) to check if a List contains...
    From 5.18, if warnings are enabled, using smart match will trigger a warning that the feature is still experimental.
    Yeah, that's really annoying. I had to use Carp::Always to figure out where those warnings were coming from in one of my scripts. Turns out it was Perl6::Junction way down in the stack. PITA.
  • Aristotle commented on Indented comments

    The way I see comments is: they are not there to say what the code is for or is supposed to – that’s what documentation is for; they are also not there to say how the code does it – the code itself should make that clear; but if after understanding what the code is for and how it goes about, your first thought would be “why on Earth does it do it this way, when it would be so much more understandable/less work/more robust/etc to do in this more obvious way”, and if the original author of the code had a good reason not to do it that way…

  • Aristotle commented on Indented comments

    Or to put it another way, the point of a comment is to stop the next maintenance programmer from trying to “improve” the code without awareness of whatever specific reason was behind the strangeness.

    (There is also a converse at work here: it tells the maintenance programmer to check if that reason still holds, and if not, to clean up the code accordingly. The trivial case of this is the well-known FIXME.)

Subscribe to feed Responses to Comments from mascip

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.