Sponsored Link •

Summary
In Joy any number is an executable program, which pushes the the number on to the stack. This begs the question: what is the type of 42? In Cat I created two separate types, but now I am rethinking that choice.
Advertisement

When I was designing Cat I started with the assumption that the type of a number such as 42, must be a function which pushes a primitive integer type onto the stack. So the type of 42 would be:
42 : ()>(int)The type of a function which yielded 42 would be:
[42] : ()>(()>(int))In Joy the operation for evaluating functions is "i". The equivalent in Cat is "eval". The type of eval in Cat currently is:
eval : (A (A:any*)>(B:any*))>(B)This meant that the following was badly typed in Cat:
42 evalThis is because eval expected a function on the top of the stack, but 42 produced a primitive on the top of the stack. You would have to instead write:
[42] eval
The decision for this type design was based on two things:
The first issue is writing the type of numbers. It appears that what is needed is the ability to name new types and express them recursively:
42 : int; int = ()>(int);The next challenge is converting to assembly code. I haven't worked out all of the details, but I believe that when generating assembly, I need to simply insert type conversion routines at key places (i.e. where an integer is being executed, or treated like a function).
Do all this seem sane and rational?
Have an opinion? Readers have already posted 6 comments about this weblog entry. Why not add yours?
If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.
Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heronlanguage.com ). Christopher is the coauthor of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com. 
Sponsored Links
