On 14-May-96 "Mama's little helper" wrote:
>>  If you don't mind, I'm going to bother you with details of my language
>for a while now as I work out the executor part.  Anyway, in my language
>there are currently 8 data types:
>
>  int          signed long
>  uint         unsigned long
>  float        floating point number

-> num [use libcalc or some such]; i.e. get rid of different numeric types.
Actually, with libcalc, you get complex #'s as well.

>  str          variable length string
>  list         list of strings
>  nlist        list of integers
>  ulist        list of unsigned integers
>  flist        list of floats

-> nlist [list of nums]

>  What I'd like some input on is the interaction between the different
>types, and maybe advice on wether or not I should bother with unsigned ints
>at all (if you want bigger numbers, use a float right?).  Besides I can add
>big int functions to the language if they're needed by putting the big int
>data into a nlist and passing that around to the functions (bigadd(),
>bigdiv(), etc.)...

Precisely.  Get rid of distinction between numerics..

>  Here is a list of interactions I have, and would like you to check over
>them, see if I'm being consistant and what other kind of interactions might
>be possible between all the data types:
>

You have a large number of numeric operations here that shouldn't even make
sense with strings and/or lists.  They do make sense with lists only if the
lists contain numerics, and then they should apply to all elements (as you
have shown).  Perhaps a good thing to do with strings would be to simply
convert to number, perform operation, and convert back.  I don't know.

>oper:  example:                        result:

>!:
Numeric operation..

>       ! "str"                         ? 0 ? ""

Makes no sense.

>       ! 1                             = 0
>       ! 0                             = 1
>       ! {0 1 2}                       = {1 0 0}

Good..

>       ! {}                            = {1}

Makes no sense.  Should return {}.

>~:
>       ~ "str"                         ? "rts"

Cute.  Could work.

>       ~ 0                             = 0xffffffff

With possible infinite #'s, you may want to go into 2 arguments: ~(n,nbits)

>       ~ {0 1 2}                       = {~0 ~1 ~2}
>       ~ {}                            ? 1

Makes no sense.

>++:
Numeric op.  Makes no sense for strings/empty list

>       ++ "str"                        ? " str"
>       "str" ++                        ? "str "
>       ++ 0                            = 1
>       ++ {0 1 2}                      = {1 2 3}
>       ++ {}                           ? {}

>--:
Numeric op.

>       -- "str"                        = "tr"
>       "str" --                        = "st"
>       -- 0                            = -1
>       -- {0 1 2}                      = {-1 0 1}
>       -- {}                           ? {}

>-: (unary)
Numeric op.

>       -"str"                          ?
>       -1                              = -1
>       -{0 1 2}                        = {-0 -1 -2}
>       -{}                             ? {}
>
>+: (unary)
Numeric op.

>       +"str"                          ?
>       +1                              = 1
>       +{-1 -2 3}                      = {1 2 3}
>       +{}                             ? {}

>*:
>       "str" * "ing"                   ?

"And" -- as in, "aab" * "cbda" -> "ab"[order from 1st string], perhaps..

>       "str" * 2                       ? "strstr"
>       2 * 2                           = 4
>       "str" * {"s1" "s2"}             = {"strs1" "strs2"}

No.  That is concatination.  Should be {"str"*"s1" "str"*"s2"} = {"s" "s"}?

>       {"str"} * {"s1" "s2"}           = {{"str" "s1"}{ "str" "s2"}}

Ok... cross product of lists. 

>       2 * {2 3 4}                     = {4 6 8}

Ok..

>       {2} * {2 3 4}                   ? {{2 2}{2 3}{2 4}} = {2 2 2 3 2 4}

Ok... no nested lists?  cross product, I guess.  How are you doing dot
product?

>       {2 3} * {2 3 4}                 ? {2 2 2 3 2 4 3 2 3 3 3 4}

Cross product, sort of.. no nested lists again.

>/:
>       "str" / "ing"                   ?

Makes no sense with your def. below.

>       "string" / 2                    ? "st"
>       "string" / 3                    ? "str"

Ok..

>       4 / 2                           = 2
>       {4 8 12 16} / 2                 ? {2 4 6 8}

Good..

>       {4 8 12 16} / {2}               ?

Makes no sense with your string def. above.

>
>%:
>       "str" % "ing"                   ?

See /.

>       "string" % 2                    ? "ng"
>       "string" % 3                    ? "ing"

ok.. goes with your def. above.

>       5 % 2                           = 1

Only works with integer, though.. not floats.  Convert to int first?

>       {5 9 14 19} % 2                 = {1 1 0 1}
>       {4 8 12 16} % {2}               ?

See /.

>+:
>       "str" + "ing"                   = "string"
>       "string" + 10                   = "str\n"

Interesting, although I would expect "string10".  That's what "str\012" is
for..

>       "str" + 32 + "ing"              = "str ing"

I'd expect "str32ing".

>       "str" + {"s1" "s2" "s3"}        = {"str" "s1" "s2" "s3"}

I would expect {"strs1" "strs2" "strs3"}

>       {"s1" "s2" "s3"} + "str"        = {"s1" "s2" "s3" "str"}

See above.

>       "str" + {0 1 2}                 = {0 0 1 2}

See above.  Depends on whether you lists are multitype or not.

>       1 + 1                           = 2
>       1 + {0 1 2}                     = {1 2 3}

You just demonstrated my reason for #2-3 above..

>       {2 1 0} + {3 4 5}               = {2 1 0 3 4 5}

Ok... hard to say.  Makes sense.

>       {} + {0 1 2}                    = {0 1 2}
>
>-:
>       "str" - "st"                    = "r"
>       "str" - "tr"                    = "s"
>       "string" - 2                    ?

Same as "string" - "2", or convert both to numeric?

>       2 - 1                           = 1
>       "st" - {"str" "ing"}            = {"r" "ing"}
>       {"str"} - {"str" "ing"}         = {"ing"}

Bzzzt.  {"str" "ing"} - {"str"} perhaps, but this should be {}.

>       {1} - {0 1 2}                   = {0 2}

See above.

>       {} - {"s1" "s2" "s3"}           = {"s1" "s2" "s3"}

???  How do you say inverted sets become positive?  See above 2.

>
><<:
>>>:
>       "str" << "ing"                  ?

Invalid..

>       "string" << 2                   = "ring"
>       1 << 4                          = 16
>       {0 1 2} << 1                    ? {1 2}
>       {0 1 2} << {1}                  ? {0 2 4}

Interesting... see point below.

>
>&:
>       "str" & "xtx"                   ? " t "
>       "string" & 2                    ?
>       2 & 3                           = 2
>       2 & {1 2 3}                     ?
>       {2} & {1 2 3}                   ?
>
>|:
>       "str" | "ing"                   ?
>       "string" | 2                    ?
>       2 | 3                           = 3
>       2 | {1 2 3}                     ?
>       {2} | {1 2 3}                   ?
>
>^:
>       "str" ^ "xtx"                   = "s r"
>       "string" ^ 2                    ?

>  Obviously where the ? is where the = should be, I'm not sure how the
>interaction should work.
>
>  What I'm not sure on at all is how I should operate on sets... If perhaps
>I should leave all list math up to discreet functions (like matmult(int
>rows, int cols, list a, list b)).  Functions BTW, are typeless, the data
>type returned is determined at runtime by the data type given to the
>"return" function.  Also arguments to a function can be given a default
>value if the function is called w/o that specific argument, like in ADA.

Perhaps you should look at a good Ada manual to see some sane operations
regarding "lists" (arrays) and strings.  Much more mathematically sane.  You
freely mix dot-type operations (distributive) with cross-type operations
(associative).  I would make things dot-style all the time, with special
operators (like perhaps the unused / and %) for cross-style combinations, or
perhaps cross-style always when dealing with lists on both sides of the
operator..  but even then use real crossing instead of list combinations.
You really need to examine your list operations more closely.

>  Also, should I support a "structure list" or a list where each element of
>a list could have a different data type.  What should the syntax of a list
>be: {a b c} or {a,b,c}, which would allow you to put expressions in lists,
>like: {a,b,var[x],d} which would be evaluated at run time.

Gee, now you're sounding like tcl.  tcl makes lists {a b c} and strings
{a b c}  (see the difference?  thought not..), so lists of strings are:
{{a b c} {c d e}}.

>  Also, right now my lists are flat, meaning that something like:
>{{a b c} d e f} gets flattened into {a b c d e f}.  Maybe it goes with
>making a structured list where you could have a list of lists (a hash table).
>Maybe I should break down and support pointers too, that wouldn't be much of
>a leap really.  I suppose I should be satisfied with good string handling,
>but there are a lot of things I want to use this language for...

Pointers?  why?  Is it really so difficult to support a decent multi-level
list access, like l[a][b][c] to get the c'th item of the b'th list of the
a'th list of l?  And how about something like Ada/Pascal "slices"?  l[a..c]
is a new array..

-----------------------------------------------------------------------------
Thomas J. Moore, ex Amiga Developer|Linux makes Intel garbage almost likeable
inet:  dark@mama.indstate.edu      |Must .... Kill .... Bugs .... AAARRRGGHHH
-----------------------------------------------------------------------------
