RE: Inflating and deflating

[prev] [thread] [next] [Date index for 2005/02/14]

From: Addison, Mark
Subject: RE: Inflating and deflating
Date: 12:40 on 14 Feb 2005
This is a multi-part message in MIME format.

------_=_NextPart_001_01C51292.635B4D39
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

From: Perrin Harkins Sent: Thu 10/02/2005 18:03
> On Thu, 2005-02-10 at 17:52 +0000, Addison, Mark wrote:
> > Sorry if I'm being dense, but I thought that was the whole point
> > of the alias that Class::Accessor (therefore CDBI) creates!
> > ie you can define a method with the _same_ name as the CDBI created
> > accessor and then use the alias method to call the origional CDBI
> > generated one. Is there a gotcha with this I'm missing?
>
> Don't you get a warning when you redefine that sub?  They are both being
> put into the same namespace.

No, Class::Accessor sorts it. It installs the method under both names
(e.g. foo and _foo_accessor) but only if that name hasn't already be
used (ie by your own sub). Works fine as long as don't call any of your
own methods _*_accessor.

From Class/Accessor.pm

            my $accessor =3D $self->$maker($field);
            my $alias =3D "_${field}_accessor";

            *{$class."\:\:$field"}  =3D $accessor
              unless defined &{$class."\:\:$field"};

            *{$class."\:\:$alias"}  =3D $accessor
              unless defined &{$class."\:\:$alias"};

mark
--

This email (and any attachments) is intended solely for the individual(s) t=
o whom addressed.=20
It may contain confidential and/or legally privileged information.=20
Any statement or opinions therein are not necessarily those of ITN unless s=
pecifically stated.=20
Any unauthorised use, disclosure or copying is prohibited.=20
If you have received this email in error, please notify the sender and dele=
te it from your system.=20
Security and reliability of the e-mail and attachments are not guaranteed.=20
You must take full responsibility for virus checking.



Independent Television News Limited,=20

Registered No. 548648 England,

VAT Reg. No: GB 756 2995 81,=20

200 Gray's Inn Road, London WC1X 8XZ,

Telephone: 020 7833 3000.


------_=_NextPart_001_01C51292.635B4D39
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.5.6980.19">
<TITLE>RE: Inflating and deflating</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>From: Perrin Harkins Sent: Thu 10/02/2005 18:03<BR>
&gt; On Thu, 2005-02-10 at 17:52 +0000, Addison, Mark wrote:<BR>
&gt; &gt; Sorry if I'm being dense, but I thought that was the whole point<=
BR>
&gt; &gt; of the alias that Class::Accessor (therefore CDBI) creates!<BR>
&gt; &gt; ie you can define a method with the _same_ name as the CDBI creat=
ed<BR>
&gt; &gt; accessor and then use the alias method to call the origional CDBI=
<BR>
&gt; &gt; generated one. Is there a gotcha with this I'm missing?<BR>
&gt;<BR>
&gt; Don't you get a warning when you redefine that sub?&nbsp; They are bot=
h being<BR>
&gt; put into the same namespace.<BR>
<BR>
No, Class::Accessor sorts it. It installs the method under both names<BR>
(e.g. foo and _foo_accessor) but only if that name hasn't already be<BR>
used (ie by your own sub). Works fine as long as don't call any of your<BR>
own methods _*_accessor.<BR>
<BR>
From Class/Accessor.pm<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $acce=
ssor =3D $self-&gt;$maker($field);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my $alia=
s =3D &quot;_${field}_accessor&quot;;<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *{$class=
.&quot;\:\:$field&quot;}&nbsp; =3D $accessor<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; unless defined &amp;{$class.&quot;\:\:$field&quot;};<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *{$class=
.&quot;\:\:$alias&quot;}&nbsp; =3D $accessor<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; unless defined &amp;{$class.&quot;\:\:$alias&quot;};<BR>
<BR>
mark<BR>
--<BR>
</FONT>
</P>

<pre>This email (and any attachments) is intended solely for the individual=
(s) to whom addressed.=20
It may contain confidential and/or legally privileged information.=20
Any statement or opinions therein are not necessarily those of ITN unless s=
pecifically stated.=20
Any unauthorised use, disclosure or copying is prohibited.=20
If you have received this email in error, please notify the sender and dele=
te it from your system.=20
Security and reliability of the e-mail and attachments are not guaranteed.=20
You must take full responsibility for virus checking.



Independent Television News Limited,=20

Registered No. 548648 England,

VAT Reg. No: GB 756 2995 81,=20

200 Gray's Inn Road, London WC1X 8XZ,

Telephone: 020 7833 3000.

</pre></BODY>
</HTML>
------_=_NextPart_001_01C51292.635B4D39--

Inflating and deflating
Simon Wilcox 19:19 on 05 Feb 2005

RE: Inflating and deflating
22:39 on 05 Feb 2005

Re: Inflating and deflating
Perrin Harkins 23:42 on 05 Feb 2005

Solved // RE: Inflating and deflating
Simon Wilcox 23:17 on 06 Feb 2005

RE: Inflating and deflating
Addison, Mark 11:07 on 08 Feb 2005

RE: Inflating and deflating
Perrin Harkins 16:21 on 08 Feb 2005

RE: Inflating and deflating
Addison, Mark 17:52 on 10 Feb 2005

RE: Inflating and deflating
Perrin Harkins 18:03 on 10 Feb 2005

RE: Inflating and deflating
Addison, Mark 12:40 on 14 Feb 2005

RE: Inflating and deflating
Perrin Harkins 20:19 on 14 Feb 2005

RE: Inflating and deflating
Addison, Mark 17:21 on 15 Feb 2005

Generated at 17:31 on 15 Feb 2005 by mariachi v0.52