Grokbase
x

Matt S Trout (dbix-...@trout.me.uk)

Profile | Posts (2029)

User Information

Display Name:Matt S Trout
Partial Email Address:dbix-...@trout.me.uk
Posts:
2029 total
101 in Catalyst Framework Development
5 in catalyst-dev@lists.scsys.co.uk
835 in Catalyst Framework
35 in catalyst@lists.scsys.co.uk
59 in Class::DBI
915 in DBIx::Class
96 in dbix-class@lists.scsys.co.uk
2 in Dojo Tookit
10 in PostgreSQL - General

5 Most Recent

All Posts
1) Matt S Trout Re: Memoizing role methods
| +1 vote
Hey, Dave, where would it be good to put this in the docs so Ovid knows which file to patch? I...
Moose
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, May 14, 2009 at 02:44:31AM -0700, Ovid wrote:
>
> ----- Original Message ----
>
> > From: Matt S Trout <dbix-class@trout.me.uk>
>
> > Looking at perldoc Memoized, it can take a subref instead, and returns
> > the wrapped routine, so:
> >
> > __PACKAGE__->meta->add_method('foo' => memoize(sub { __PACKAGE__ }));
>
>
> Thanks Matt. That's what I need.

Hey, Dave, where would it be good to put this in the docs so Ovid knows
which file to patch?

I figure we want to use this as a specific example of a general thing to
know in roles, right?

--
        Matt S Trout         Catalyst and DBIx::Class consultancy with a clue
Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/
2) Matt S Trout Re: Memoizing role methods
| +1 vote
Looking at perldoc Memoized, it can take a subref instead, and returns the wrapped routine, so:...
Moose
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Wed, May 13, 2009 at 07:24:23AM -0700, Ovid wrote:
>
> In short, you can't:
>
>     #!/usr/bin/env perl -l
>
>     {
>         package My::Role;
>         use Moose::Role;
>         use Memoize;
>
>         memoize('foo');
>         sub foo { __PACKAGE__ }

Looking at perldoc Memoized, it can take a subref instead, and returns
the wrapped routine, so:

__PACKAGE__->meta->add_method('foo' => memoize(sub { __PACKAGE__ }));

should work fine. So should

*foo = Sub::Name::subname 'My::Role::foo' => memoize('foo');
sub foo { __PACKAGE__ }

and so should pretty much any variant thereon.

Maybe this wants documenting somewhere in Moose for people who don't read the
Memoize docs?

--
        Matt S Trout         Catalyst and DBIx::Class consultancy with a clue
Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/
3) Matt S Trout Re: syntax for macros / function composition at compile time
| +1 vote
That's not what attributes do though, they call a class method at a random point when the sub...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Thu, Nov 06, 2008 at 04:59:41AM -0800, Michael G Schwern wrote:
> I still say subroutine attributes are the way. That's the syntax for
> attaching things to a subroutine in Perl 5. I'd make a decorate() attribute
> and pass it the decorators.

That's not what attributes do though, they call a class method at a random
point when the sub doesn't have a name yet and then you do a crazy dance to
try and do something useful with them.

We hates attributes, we do.

> sub incr : decorate(memoize, log($file)) {
>     $_[0] + 1;
> }

Meh. How about

memoized logged (to => $file) sub incr (Int $i) {
  $i + 1;
}

?

We can certainly decorate 'method' like that. Not sure if it's possible
with sub; when rafl took over trying to make sub signatures work I kind of
forgot most of what little I'd worked out about how 'sub' is parsed in
statement form.

Better still, how about we shift off to the perl5-syntax list and stop
bothering p5p until we have something worth shoving into core? :)

--
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
4) Matt S Trout [Dbix-class] Patch roundup time, again.
| +1 vote
Other than the bigass diff to sqlite.sql, is there anything left to do here? If not, lob me an...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Mon, Oct 06, 2008 at 12:10:42AM +0200, Jens Gassmann wrote:
> Hi,
>
> >Any outstanding patches, please send to this thread. Can somebody also
> >go through rt.cpan.org and work out if there's anything on there we need
> >to apply as well?
>
> attached the test and patch for DBIx::Class::InflateColumn::Datetime

Other than the bigass diff to sqlite.sql, is there anything left to do here?

If not, lob me an htpasswd line and I'll set you up to commit this.

> The recreation of the test-schema generates many changes - many more
> then my :-(

Diffs against sqlite.sql are irrelevant - the only reason it's in svn at all
is for the (now vanishingly small) number of people patching DBIC who don't
have SQL::Translator.

Might actually just have Makefile.PL create it and drop the damn thing from
svn entirely - thoughts people?

--
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
5) Matt S Trout [Dbix-class] Probleme with nextval() and postgresql 7.4.17
| +1 vote
DBIC_TRACE=1 perl myscript.pl and see what queries you're running. Also please note it's...
dbix-class@lists.scsys.co.uk
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Tue, Oct 07, 2008 at 10:54:30AM +0200, Ludovic Legrand wrote:
> hi,
> I want to select the nextval of the sequence 'seq_id_comparison' of the
> table 'Comparison' with this line:
>
> $dbh->resultset('Comparison')->search(undef, {
> select => "nextval('seq_id_comparison')",
>       as => 'id_comp',
>       })->single->get_column('id_comp');
> SQL equivalent:
> SELECT NEXTVAL('seq_id_comparison');
>
> The SQL statement gives last_value + 1, that's ok, while the DBIx
> request gives something like last_value + 500 ...
> How to explain this increment ?

DBIC_TRACE=1 perl myscript.pl

and see what queries you're running.

Also please note it's DBIx::Class or DBIC, DBIx:: contains lots of other
projects.

--
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/

spacer
Profile | Posts (2029)
Home > People > Matt S Trout