git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 5/7] gitweb: auxiliary functions to group data

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 17, 2010, 17:17 UTC
Message-ID
<201009171917.44979.jnareb@gmail.com>
In-Reply-To
<AANLkTikjLNva7Jgh0xYeah1maFusfOiaLwY7+eixx8so@mail.gmail.com>
On Fri, 17 Sep 2010, Giuseppe Bilotta wrote:
Show 32 quoted lines
> On Fri, Sep 17, 2010 at 6:06 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>> Giuseppe Bilotta wrote:
>>> On Fri, Sep 17, 2010 at 3:24 AM, Jakub Narebski <jnareb@gmail.com> wrote:
>>>>
>>>> ... but I think that having separate subroutines for opening and
>>>> closing tags is a bad design / bad API (except in some rare cases).
>>>> It is begging for unbalanced HTML.
>>>>
>>>> It would be better if it was a single subroutine wrapping 'div' around
>>>> contents given either as a string, or via callback (subroutine reference),
>>>> in my opinion.
>>>
>>> I'm not sure that in this case the string or callback approach would
>>> be any cleaner. I'll see if perl supports closures or something like
>>> that.
>>
>> Perl supports closures (thanks to anonymous subroutines 'sub { ... }'
>> and lexical variables 'my $var'), see perlsub and "Function Templates"
>> in perlref.
>>
>> I also recommend free ebook "Higher-Order Perl" http://hop.perl.plover.com/
> 
> Thanks for the suggestion. I'm still not convinced that such an
> implementation would be better though. Aside from the general
> aesthetical suckiness of passing closures around (and the experience
> is not any more pleasurable in Perl), there's also the matter of the
> calling convention to use. I can think of two options:
> 
> (1) we make the function callable as git_do_group($class, $id, sub {
> <closure that prints the content> }, <paramters that go to
> git_print_header_div>), which is somewhat illogical since we're
> specifying the content before the header, 
Why not
  git_do_group($class, $id, <print_header_div parameters>, sub { ... })

or even use subroutine prototypes? We can use 'pop @_' to get last argument of a subroutine.

[...]
> Overall, I still get the impression that the current API is
> considerably cleaner, even with the small counterweight of the risk of
> leaving groups open (which is not something so dramatic anyway, IMO).
Might be.

But as currently git_*group() is used in only one place, isn't it premature generalization ;-) ?

-- 
Jakub Narebski
Poland
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 23 of 42 in “gitweb: allheads feature”
  1. 0/7 gitweb: allheads featureGiuseppe Bilotta, Sep 16, 2010
  2. 1/7 gitweb: introduce remote_heads featureGiuseppe Bilotta, Sep 16, 2010
  3. Jakub NarebskiSep 16, 2010
  4. Giuseppe BilottaSep 17, 2010
  5. 2/7 gitweb: git_get_heads_list accepts an optional list of refs.Giuseppe Bilotta, Sep 16, 2010
  6. Jakub NarebskiSep 16, 2010
  7. Giuseppe BilottaSep 17, 2010
  8. 3/7 gitweb: separate heads and remotes listsGiuseppe Bilotta, Sep 16, 2010
  9. Ævar Arnfjörð BjarmasonSep 16, 2010
  10. Giuseppe BilottaSep 16, 2010
  11. Jakub NarebskiSep 16, 2010
  12. Ævar Arnfjörð BjarmasonSep 16, 2010
  13. Jakub NarebskiSep 16, 2010
  14. 4/7 gitweb: link heads and remotes viewGiuseppe Bilotta, Sep 16, 2010
  15. Jakub NarebskiSep 16, 2010
  16. Giuseppe BilottaSep 17, 2010
  17. 5/7 gitweb: auxiliary functions to group dataGiuseppe Bilotta, Sep 16, 2010
  18. Ævar Arnfjörð BjarmasonSep 16, 2010
  19. Jakub NarebskiSep 17, 2010
  20. Giuseppe BilottaSep 17, 2010
  21. Jakub NarebskiSep 17, 2010
  22. Giuseppe BilottaSep 17, 2010
  23. Jakub NarebskiSep 17, 2010
  24. Giuseppe BilottaSep 18, 2010
  25. 6/7 gitweb: group stylingGiuseppe Bilotta, Sep 16, 2010
  26. Jakub NarebskiSep 17, 2010
  27. Giuseppe BilottaSep 17, 2010
  28. Jakub NarebskiSep 17, 2010
  29. 7/7 gitweb: group remote headsGiuseppe Bilotta, Sep 16, 2010
  30. Ævar Arnfjörð BjarmasonSep 16, 2010
  31. Giuseppe BilottaSep 16, 2010
  32. Jakub NarebskiSep 17, 2010
  33. Jakub NarebskiSep 17, 2010
  34. Giuseppe BilottaSep 19, 2010
  35. Jakub NarebskiSep 19, 2010
  36. Giuseppe BilottaSep 20, 2010
  37. Jakub NarebskiSep 20, 2010
  38. Giuseppe BilottaSep 20, 2010
  39. Jakub NarebskiSep 22, 2010
  40. Giuseppe BilottaSep 22, 2010
  41. Jakub NarebskiSep 16, 2010
  42. Giuseppe BilottaSep 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.