Re: Using include and namespaces

new topic     » goto parent     » topic index » view thread      » older message » newer message

Irv <irv at take.maxleft.com> wrote:

<snip>
> Dave Cuny had this feature - the ability to create multiple instances
> from a single file included multiple times - in an 
> early version of his Py (mmm... pie!) interpreter. 

> As soon as I pointed out how handy it was, he removed it. 
> Too bad. I was using it somewhat as follows 
> (using Euphoria syntax, not Py)

> include address.e as customer
> include address.e as vendor
> include address.e as company

> customer:name = "Joe Smith"
> company:name = "Footless Corp."
> etc..

> The alternative, to copy the same file under three different names, 
> is exactly as you say, plain silly.

> Irv

Maybe I don't understand the problem ...
I assume address.e will contain functions and procedures, why should
they be duplicated? The same functions and procedures can work on
different data, so what's wrong with the "classic" approach:

-------------------------------------------------------------
include address.e   -- say it defines a global type address,
                    --   global constants SIZEOF_ADDRESS,
                    --   NAME, ...

address customer, vendor, company

customer = repeat(0, SIZEOF_ADDRESS)
vendor   = repeat(0, SIZEOF_ADDRESS)
company  = repeat(0, SIZEOF_ADDRESS)

customer[NAME] = "Joe Smith"
company[NAME] = "Footless Corp."
etc..
-------------------------------------------------------------

Regards,
   Juergen

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu