Re: Namespaces (2)

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

Since there seems to be no upside to allowing multiple imports to refer to the
SAME variable space, let's investigate what happens it they point to SEPARATE
instances of the named variable space:

We gain the ability to do things like:
 import "addrbook.pi" as Customer
 import "addrbook.pi" as Vendor

and given that the file "addrbook.pi" has variables such as:
name = ""
addr = ""
city = ""
phone = ""......

then we can say:

Customer.name =  "Homer Simpson"
Customer.phone =  "555-1234"
Vendor.name = "Ace Services"
Vendor.phone = "994-2333"
===========

If we weren't allowed to do multiple imports, there are at least two ways to
achieve the same results:

1. We could just copy, rename, and include under the new name, copies of the
    original "addrbook" file. That has drawbacks; more files to handle, and the
     meed to edit multiple files when there is a code change. I rate this
     option with a -2 (not worth considering)

2. We could do as we do now - create and structure a sequence, import it, make
    a copy named Customer, and another named Vendor, and refer to them as:
    Customer[NAME] = "Homer Simpson"
    Vendor[NAME] = "Ace Services".....
     This has some additional capability, so I rate it +1

=============

So is there any advantage to allowing multiple imports?
Maybe. Primarily for small programs written by those new to the concept
of, or annoyed by, "sequences".  It's a minor thing, but as I can see no harm
resulting from  having the ability, why not leave it in. Someone may find a
surprising new  use for it.

All this, however has brought to the surface a nasty problem in regards to
namespacing.  Basically, unless Dave can find a way around this problem,
namespacing will be of little practical value. I'll cover that in the next post.

Regards,
Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu