On Sun, Sep 5, 2010 at 10:42 PM, Chris Marshall <[email protected]> wrote:
> On 9/5/2010 11:03 PM, Craig DeForest wrote:
>>
>> There is some pretty basic syntax in "use" to specify which items are
>> exported to the current package. It doesn't work well with bundles (like
>> "use PDL"), though.
>>
>> I think we discussed going to a strict object mode (no exports) some years
>> ago -- do any of the other old-timers remember that? My recollection is that
>> nobody wanted it at that time, or at least nobody wanted it enough to
>> actually do anything about it.
>>
>>
>>
>> On Sep 5, 2010, at 7:43 PM, P Kishor wrote:
>>
>>> On Sun, Sep 5, 2010 at 8:22 PM, Craig DeForest
>>> <[email protected]> wrote:
>>>>
>>>> Easiest way:
>>>>
>>>> begin {package foo; use PDL; }
>>>>
>>>> Will export all those routines to foo rather than main. I have not tried
>>>> setting foo to 'PDL'.
>>>
>>>
>>> Thanks Craig. I will try the above. That might do the trick for now.
>>>
>>> I realized (while on a bike ride outside), that all this would be a
>>> non-issue if all PDL methods were strictly object methods. Perhaps,
>>> the developers can think of a pragma for the next version that would
>>> enforce that. That way there would never be any methods exported, and
>>> never any collision.
>
> I thought that was what PDL::Lite was for.  It exports nothing
> into your namespace and you have to fully qualify subs or use
> method syntax.  As in the description of PDL::Lite says:
>
>  "Loads the smallest possible set of modules for PDL to work,
>   without importing an functions in to the current namespace.
>   This is the absolute minimum set for PDL.  Although no functions
>   are defined (apart from a few always exported by PDL::Core) you
>   can still use method syntax, viz:..."
>
> I don't know which ones are being exported by Core, if those
> are the conflicting ones then something would need to be done
> to deconflict.  Maybe if PDL::Lite takes you 90% of the way,
> you could ask Perl Dancer to come the other 10%.  If that is
> not possible, a feature request is in order.
>
> My personal opinion is that there should be a no-export
> flavor of PDL available and if PDL::Lite is not it, maybe
> we need to revisit the discussion for ways to resolve the
> problem.
>
> @PKishor: does PDL::Lite do what you need?


Chris, yes, possibly. I commented out all PDL modules, added
PDL::Lite, and then converted stuff such as `zeroes $x, $y` to
PDL->zeroes($x, $y). So far so good. Things will break, but I guess I
can try the PDL->method method. By the way, `PDL->zeroes $x, $y`
doesn't work. I have to use parens as in `PDL->zeroes($x, $y)`.

We'll see. I will have to do more testing, step by step. Many thanks
for your help.

I have also written to the Dancer folks and see if they can suggest
solutions as well. Hopefully, I won't need anything drastic.

I do hope that one day PDL might evolve into a completely object
oriented program, with all the methods accessible only via the piddle
object.


>
> --Chris
>
>>>
>>>>
>>>> (Mobile)
>>>>
>>>>
>>>> On Sep 5, 2010, at 6:33 PM, P Kishor <[email protected]> wrote:
>>>>
>>>>> On Sun, Sep 5, 2010 at 5:31 PM, Chris Marshall <[email protected]>
>>>>> wrote:
>>>>>>>
>>>>>>> Hi Chris, I know you want to lead me to the answer, but I am not sure
>>>>>>> where you are pointing me to. I have looked at "help PDL" and
>>>>>>> "perldoc
>>>>>>> PDL" and the only item of relevance to me here I see is
>>>>>>>
>>>>>>> "Exports
>>>>>>> use PDL; exports a large number of routines into the calling
>>>>>>> namespace. If you want to avoid namespace pollution, you must instead
>>>>>>> use PDL::Lite, and include any additional modules explicitly."
>>>>>>
>>>>>> If you want to avoid namespace pollution, you must instead
>>>>>> use PDL::Lite, and include any additional modules explicitly.
>>>>>
>>>>>
>>>>> Seems like you told me what I have already read but haven't found
>>>>> helpful.
>>>>>
>>>>> Let me explain again... I use a module that has defined methods called
>>>>> 'any' and 'get'. Now, when I use PDL, those methods get redefined. It
>>>>> really doesn't matter whether I 'use PDL' or 'use PDL::Lite' and then
>>>>> 'use PDL::Basic' and 'use PDL::Ufunc' and 'use PDL::Core'. What is
>>>>> needed is a way to import PDL commands into a custom namespace... the
>>>>> best would be to have them all available as PDL::* as that would
>>>>> ensure I will never have any collision with any package ever.
>>>>>
>>>>>
>>>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to