cc: [email protected]
Subject: Re: [ast-developers] typeset -T ksh crash
--------

> it seems easy to fix, but I've never used it and even don't know
> what typeset -T should do?
> 
> I've tried
> typeset -T abc=hello; typeset -T
> which outputs
> typeset -T abc
> typeset -T abc=hell)
> 
> and that did not help to understand it, especially missing last 
> letter and extra parenthesis. So I don't know if it should print
> both "typeset -T abc" and "typeset -T abc=" or just first one.
> 
> Michal
> 

typeset -T is used to create user defined types or to list the current
types and their definitions. 

A type is defined with
        typeset -T name=(...)
Note the assignment typeset -T abc is not valid and it should have
produced an error (which it now does).

typeset -T abc

is legal and should list all variables of type T

typeset -T should list all type definitions.

Here is an example of a type definition:

        typeset -T Pt_t=(
                float x=1
                float y=0
                len(){
                        print $(( sqrt(_.x**2+_.y**2)))
                } 
        )
This creates a builtin named Pt_t which is a constructor for this type.
        Pt_t    p q=(x=3 y=4)
This creates two instance of type Pt_t.
The function len is a discipline function and _ will be a reference to
the instance that invoked it.  Each instance can redefine their own
version of these functions.

        p.len
outputs 1 and
        q.len
outputs 5.

David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to