At 11:25 AM +0200 6/16/04, Leopold Toetsch wrote:
Dan Sugalski <[EMAIL PROTECTED]> wrote:
 *) We consider ways to make slices. I can see ops, or I can see basic
 functions. Either is fine, depends on how often the things are used.

I'll start from the end of the proposal. What about just extending the keyed syntax:

    Px = Py[0]           # key
    Px = Py["a"; 1]      # multi key
    Px = Py[0..2, 4]     # slice
    Px = Py["a", "b"]    # slice
    Px = Py[I0, I1..]    # slice

So a slice PMC is basically a Key PMC with two additional flags per key
component: start_range .. end_range. The comma starts a new key
component. Key components are typed and constructed at compile time, so
we would have already what we need with low overhead.

That works for me. We'll want the slice to return a different PMC type than a key so we can tell 'em apart, but other than that it's good.


BTW: is there something like:

   Px = Py["a".."x"]

or even

Px = Py["aaa".."xxx"]

Yes. Which reminds me--we need to have a syntax to distinguish between key types. A key value can be an int, string, or PMC, and it can be taken as an int, string, or PMC. Someone could do:


   Px = Py[Sx]

but want Sx to be taken as an int for array access rather than a string for key access. While that's an unusual case, this:

   Px = Py[Pz]

won't be, and we'll need to note whether Pz should be taken as an int, string, or PMC. (PMC for the fancier keying of hashes)

As I remember there were bits in key entries to note both the type of the key value and how the key value should be taken, so I'd like to add syntax for this at the pir/pasm level. A simple :i, :s, :p (for int, string, or pmc) suffix to the key would be fine, with a missing suffix defaulting to the type of the value. (So ints default to :i, strings to :s, and pmcs to :p)
--
Dan


--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to