Skip Menu |
 

This queue is for tickets about the Class-XSAccessor CPAN distribution.

Report information
The Basics
Id: 72829
Status: stalled
Priority: 0/
Queue: Class-XSAccessor

People
Owner: Nobody in particular
Requestors: ribasushi [...] leporine.io
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Cached accessors - minor problem
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1552
Download (untitled) / with headers
text/plain 1.5k
I just saw 1.12_01 being released - the cached accessor stuff is an awesome awesome idea. It in fact obviates the need for me to deal with the CAG inherited type we were talking about (more detail about implementation here: https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped-0.10004/lib/Class/Accessor/Grouped.pm#L237) However there is a problem - the method names. First of all they are short and common enough to virtually guarantee clashes with existing software. For example I can not add a _set method to the DBIC ResultClass inheritance chain, as there is an extremely high chance an actual user of said library already has such methods. I propose something like _xsa_cached_get / _xsa_cached_set. Furthermore the way you implemented this it will be quite complicated to retrofit it into larger frameworks like Moo or Class::Accessor::Grouped, as we now need to implement a flexible accessor dispatch table inside the _set/_get subs (i.e. what to do on 'foo', what to do on 'bar', etc). Again CAG is a good example on why this is a problem: https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped-0.10004/lib/Class/Accessor/Grouped.pm#L100. We currently only use XSA for the 'simple' type (and go to hreat lengths to make sure we do not short-circuit a user-defines get/set_simple, e.g. https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped-0.10004/lib/Class/Accessor/Grouped.pm#L654) Is it possible to compile the accessor name into the method as well? Something like _xsa_cached_get_foo / _xsa_cached_set_foo? Cheers!
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-6895-1322681127-1250.72829-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1447
Download (untitled) / with headers
text/plain 1.4k
On Wed Nov 30 02:43:16 2011, RIBASUSHI wrote: Show quoted text
> Furthermore the way you implemented this it will be quite complicated > to > retrofit it into larger frameworks like Moo or > Class::Accessor::Grouped, > as we now need to implement a flexible accessor dispatch table inside > the _set/_get subs (i.e. what to do on 'foo', what to do on 'bar', > etc). > Again CAG is a good example on why this is a problem: > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- > 0.10004/lib/Class/Accessor/Grouped.pm#L100. > We currently only use XSA for the 'simple' type (and go to hreat > lengths > to make sure we do not short-circuit a user-defines get/set_simple, > e.g. > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- > 0.10004/lib/Class/Accessor/Grouped.pm#L654) > Is it possible to compile the accessor name into the method as well? > Something like _xsa_cached_get_foo / _xsa_cached_set_foo?
It seems to me that what I really want is to be able to pass a method name (and, if possible, have a choice of passing a coderef as well) plus some static arguments to be passed thereto - and then you're effectively defaulting the names to _get/_set and the arguments to $attr_name. The other thing that I'd really like to have here is to be able to have -only- the _get or _set behaviour on any given accessor - for example I could use _set only to implement set-with-type-checks or _get only to implement lazyily-calculated-defaults.
From smueller [...] cpan.org Thu Dec 1 02: 06:45 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-5.442 tagged_above=-99.9 required=10 tests=[AWL=1.458, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-6895-1322681127-1510.72829-5-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-72829 [...] rt.cpan.org> <rt-3.8.HEAD-6895-1322681127-1510.72829-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4ED72775.5060901 [...] cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
X-Spam-Score: -5.442
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id EF7E9240F90 for <cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com>; Thu, 1 Dec 2011 02:06:44 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lFdhB6kacCIA for <cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com>; Thu, 1 Dec 2011 02:06:43 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 04023240EC0 for <bug-Class-XSAccessor [...] rt.cpan.org>; Thu, 1 Dec 2011 02:06:42 -0500 (EST)
Received: (qmail 15457 invoked by uid 103); 1 Dec 2011 07:06:40 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 1 Dec 2011 07:06:40 -0000
Received: from caiajhbdcahe.dreamhost.com (HELO homiemail-a95.g.dreamhost.com) (208.97.132.74) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Wed, 30 Nov 2011 23:06:38 -0800
Received: from homiemail-a95.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a95.g.dreamhost.com (Postfix) with ESMTP id 835DA1E06C for <bug-Class-XSAccessor [...] rt.cpan.org>; Wed, 30 Nov 2011 23:06:35 -0800 (PST)
Received: from [192.168.1.10] (unknown [62.140.137.79]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: catch-all [...] steffen-mueller.net) by homiemail-a95.g.dreamhost.com (Postfix) with ESMTPSA id C3F0C1E06B for <bug-Class-XSAccessor [...] rt.cpan.org>; Wed, 30 Nov 2011 23:06:34 -0800 (PST)
Delivered-To: cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15
Subject: Re: [rt.cpan.org #72829] Cached accessors - minor problem
Return-Path: <smueller [...] cpan.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com
X-RT-Mail-Extension: class-xsaccessor
Date: Thu, 01 Dec 2011 08:06:29 +0100
X-Spam-Level:
To: bug-Class-XSAccessor [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Steffen Mueller <smueller [...] cpan.org>
RT-Message-ID: <rt-3.8.HEAD-12654-1322723205-1980.72829-0-0 [...] rt.cpan.org>
Content-Length: 2942
Download (untitled) / with headers
text/plain 2.8k
On 11/30/2011 08:25 PM, MSTROUT via RT wrote: Show quoted text
> Queue: Class-XSAccessor > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=72829> > > On Wed Nov 30 02:43:16 2011, RIBASUSHI wrote:
>> Furthermore the way you implemented this it will be quite complicated >> to >> retrofit it into larger frameworks like Moo or >> Class::Accessor::Grouped, >> as we now need to implement a flexible accessor dispatch table inside >> the _set/_get subs (i.e. what to do on 'foo', what to do on 'bar', >> etc). >> Again CAG is a good example on why this is a problem: >> https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- >> 0.10004/lib/Class/Accessor/Grouped.pm#L100. >> We currently only use XSA for the 'simple' type (and go to hreat >> lengths >> to make sure we do not short-circuit a user-defines get/set_simple, >> e.g. >> https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- >> 0.10004/lib/Class/Accessor/Grouped.pm#L654) >> Is it possible to compile the accessor name into the method as well? >> Something like _xsa_cached_get_foo / _xsa_cached_set_foo?
> > It seems to me that what I really want is to be able to pass a method > name (and, if possible, have a choice of passing a coderef as well) plus > some static arguments to be passed thereto - and then you're effectively > defaulting the names to _get/_set and the arguments to $attr_name. > > The other thing that I'd really like to have here is to be able to have > -only- the _get or _set behaviour on any given accessor - for example I > could use _set only to implement set-with-type-checks or _get only to > implement lazyily-calculated-defaults.
This reply applies to both of you, not just Matt. I didn't do any of this because that requires hacking on the C-level storage for the hash keys. Right now, it sports exactly 1-to-1 mapping of hash key strings to integers with lookup either way. Shoving more info in there without a) Slowing down the simple cases (possibly by quite a bit) b) Breaking the terrible and likely fragile code that implements the out-of-perl storage. c) Breaking it specifically wrt. thread-safety. Now, all of these may be irrational fear, so don't let me discourage you from hacking on it (and cleaning it up as you see fit, but please be available for debugging weird issues if you break it). For me, however, I simply needed exactly the behaviour of the current implementation of cached accessors for $work (we have a weirdly twisted variant of a formerly-Class::DBI ORM that we can't migrate away from and don't generally give a flying fuck about anyway). What you propose is a superset of what I need, so that'll work for me, too. Just be aware that a) I don't have the time to implement it and b) any call back into Perl from C is going to be so mind-numbingly slow that you could have done the whole thing in Perl from the get-go. So make sure the common case doesn't have to do that. Cheers, Steffen
From smueller [...] cpan.org Thu Dec 1 03: 23:46 2011
MIME-Version: 1.0
X-Spam-Status: No, score=-6.9 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-6892-1322638996-1535.72829-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-72829 [...] rt.cpan.org> <rt-3.8.HEAD-6892-1322638996-1535.72829-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4ED7397F.6010903 [...] cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.9
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B47A0240ED3 for <cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com>; Thu, 1 Dec 2011 03:23:46 -0500 (EST)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zGFTF9X+J3Un for <cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com>; Thu, 1 Dec 2011 03:23:45 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 12050240EC0 for <bug-Class-XSAccessor [...] rt.cpan.org>; Thu, 1 Dec 2011 03:23:44 -0500 (EST)
Received: (qmail 21368 invoked by uid 103); 1 Dec 2011 08:23:44 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 1 Dec 2011 08:23:44 -0000
Received: from mail-out3.booking.com (HELO mail-out3.booking.com) (91.195.237.20) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Thu, 01 Dec 2011 00:23:41 -0800
Received: from corpds-101.ams4.corp.booking.com ([10.196.68.22]:36593) by mtx-101.ams4.prod.booking.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from <smueller [...] cpan.org>) id 1RW1vd-0005q9-Sc for bug-Class-XSAccessor [...] rt.cpan.org; Thu, 01 Dec 2011 09:23:37 +0100
Received: from ams7-dhcp-82-228.ams7.corp.booking.com ([10.154.82.228]:55439) by corpds-101.ams4.corp.booking.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from <smueller [...] cpan.org>) id 1RW1vd-0003SG-LE for bug-Class-XSAccessor [...] rt.cpan.org; Thu, 01 Dec 2011 09:23:37 +0100
Delivered-To: cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15
Subject: Re: [rt.cpan.org #72829] Cached accessors - minor problem
Return-Path: <smueller [...] cpan.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Class-XSAccessor [...] hipster.bestpractical.com
X-RT-Mail-Extension: class-xsaccessor
Date: Thu, 01 Dec 2011 09:23:27 +0100
X-Spam-Level:
To: bug-Class-XSAccessor [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Steffen Mueller <smueller [...] cpan.org>
RT-Message-ID: <rt-3.8.HEAD-13645-1322727827-1935.72829-0-0 [...] rt.cpan.org>
Content-Length: 1469
Download (untitled) / with headers
text/plain 1.4k
On 11/30/2011 08:43 AM, Peter Rabbitson via RT wrote: Show quoted text
> However there is a problem - the method names. First of all they are > short and common enough to virtually guarantee clashes with existing > software. For example I can not add a _set method to the DBIC > ResultClass inheritance chain, as there is an extremely high chance an > actual user of said library already has such methods. I propose > something like _xsa_cached_get / _xsa_cached_set.
That would be easy and I'd be happy to do that. Show quoted text
> Furthermore the way you implemented this it will be quite complicated to > retrofit it into larger frameworks like Moo or Class::Accessor::Grouped,
Large framework like Moo? IMO, that's a failure right there. No offense, Matt! Show quoted text
> as we now need to implement a flexible accessor dispatch table inside > the _set/_get subs (i.e. what to do on 'foo', what to do on 'bar', etc). > Again CAG is a good example on why this is a problem: > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped-0.10004/lib/Class/Accessor/Grouped.pm#L100. > We currently only use XSA for the 'simple' type (and go to hreat lengths > to make sure we do not short-circuit a user-defines get/set_simple, e.g. > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped-0.10004/lib/Class/Accessor/Grouped.pm#L654)
Show quoted text
> Is it possible to compile the accessor name into the method as well? > Something like _xsa_cached_get_foo / _xsa_cached_set_foo?
Not easily/efficiently. --Steffen
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-6895-1322681127-1250.72829-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-6895-1322681127-1250.72829-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-6892-1323185864-1051.72829-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2575
Download (untitled) / with headers
text/plain 2.5k
On Wed Nov 30 14:25:27 2011, MSTROUT wrote: Show quoted text
> On Wed Nov 30 02:43:16 2011, RIBASUSHI wrote:
> > Furthermore the way you implemented this it will be quite
complicated Show quoted text
> > to > > retrofit it into larger frameworks like Moo or > > Class::Accessor::Grouped, > > as we now need to implement a flexible accessor dispatch table
inside Show quoted text
> > the _set/_get subs (i.e. what to do on 'foo', what to do on 'bar', > > etc). > > Again CAG is a good example on why this is a problem: > > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- > > 0.10004/lib/Class/Accessor/Grouped.pm#L100. > > We currently only use XSA for the 'simple' type (and go to hreat > > lengths > > to make sure we do not short-circuit a user-defines get/set_simple, > > e.g. > > https://metacpan.org/source/RIBASUSHI/Class-Accessor-Grouped- > > 0.10004/lib/Class/Accessor/Grouped.pm#L654) > > Is it possible to compile the accessor name into the method as well? > > Something like _xsa_cached_get_foo / _xsa_cached_set_foo?
> > It seems to me that what I really want is to be able to pass a method > name (and, if possible, have a choice of passing a coderef as well)
plus Show quoted text
> some static arguments to be passed thereto - and then you're
effectively Show quoted text
> defaulting the names to _get/_set and the arguments to $attr_name. > > The other thing that I'd really like to have here is to be able to
have Show quoted text
> -only- the _get or _set behaviour on any given accessor - for example
I Show quoted text
> could use _set only to implement set-with-type-checks or _get only to > implement lazyily-calculated-defaults.
I thought some more about the general problem of adding more meta- information to the generated accessors. It's a bit nasty. Since that's thinking I've done before, I added some comments to the code for the Steffen of the future to read instead of redoing the whole thought thing: https://github.com/tsee/Class- XSAccessor/commit/5590225024cb52adf187b45113544ff36a5516fa Hope that makes some sense. So if we want this further parameterization, we'll have to reconsider more of the implementation and algorithms in the module. BTW: The thread-safety issue that I discovered the other day is fixed in the master branch now. Maybe this will allow us to recover cygwin! Yay! On further reflection, it should be possible to include the hash key name into the _get/_set-alike method to call without too much pain. But that would be most elegantly solved by further parametization to avoid some of the ludicrous code duplication that's already going on. So I'm punting on it for the time being. Cheers, Steffen


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.