MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Putting the same function name in multiple modules.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54790] Re: Putting the same function name in multiple modules.
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 2 Mar 2005 01:26:37 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <d0154m$ovc$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

set the context explicit ? Something like

   Begin["`Private`"];
    Global`Doit[x_FooA] := ...;
    End[];

and in the second context

    Begin["`Private`"];
    Global`Doit[x_FooB] := ...;
    End[];

Regards
  Jens

"Josef Karthauser" <joe at tao.org.uk> schrieb im Newsbeitrag 
news:d0154m$ovc$1 at smc.vnet.net...
>
> I'm trying to do a bit of "object orientation" with a number of modules
> and was wondering what the official way of doing it was.
>
> Imagine that I've got a couple of data types defined.  Let us call them
> FooA[] and FooB[].  Each has it's own module, so that I can do something
> like:
>
>    Needs["`FooA`"];
>    Needs["`FooB`"];
>
> What I want is a function that can operate on both types, i.e.
>
>    Doit[x_FooA] := ...
>
> and
>
>    Doit[x_FooB] := ...
>
> and would like to define each of these in the relevant module.
>
> I would normally do something like:
>
>    Module[... FooA ...]
>
>    Doit::usage = "....";
>
>    Begin["`Private`"];
>    Doit[x_FooA] := ...;
>    End[];
>
> and
>
>    Module[... FooB ...]
>
>    Doit::usage = "....";
>
>    Begin["`Private`"];
>    Doit[x_FooB] := ...;
>    End[];
>
> Of course doing it this way each of the Doit[] functions is defined in a
> different context and so one of them gets overriden by the other.
>
> Does anyone know how I can fix things so that I can say make a FooC
> module and define a Doit[x_FooC] in it without having to change the FooA
> and FooB modules to accomodate it.
>
> Thanks,
> Joe
> --
> Josef Karthauser (joe at tao.org.uk)        http://www.josef-k.net/
> FreeBSD (cvs meister, admin and hacker)     http://www.uk.FreeBSD.org/
> Physics Particle Theory (student)   http://www.pact.cpes.sussex.ac.uk/
> ================ An eclectic mix of fact and theory. =================
> 



  • Prev by Date: Re: Graphic resizing problem Linux notebook--FIXED
  • Next by Date: Re: Plot3D gives serrated ridge
  • Previous by thread: Putting the same function name in multiple modules.
  • Next by thread: Re: Polygons on spheres