smilax:: ParentheTcl : [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   

[Bedstraw] *smilax*
 
[Mega-Changes]
[Mega-Calendar]

ParentheTcl

( see Downloads at bottom of page )

ParentheTcl (pronounced "parenTHETical," abbreviated "p7tcl" or "P7") is a safe language for writing fast, compiled extensions for Tcl.

Purpose

ParentheTcl is designed primarily for doing things that either are Really Slow or that you Just Can't do in Tcl:

Compatability with Tcl

Functions written in ParentheTcl show up as commands in Tcl when the compiled module is loaded. ParentheTcl remains Tcl-ish in style and syntax, as well as in compatability of its data types and exception handling.

Safety

Like Tcl, ParentheTcl is automatically memory-managed, so exploits due to memory errors should not occur (once the compiler and runtime are debugged!). Array bounds are checked, pointers are checked for null, and reference counting is used to free memory objects.

Parenthesized Extensions

ParentheTcl extends the syntax and semantics of Tcl in three fundamental ways, all marked by the use of parentheses:

A Few Small P7 Examples

Define the triangle of n to be 1+2+3+...+n. Triangle is like factorial, but uses addition instead of multiplication so the numbers don't overflow so fast. Here's a straightforward recursive definition of triangle:

p7proc (int)triangle_recursive { (int)x } {
    if ( $x < 1 ) { return 0 }
    return ( $x + [triangle_recursive ($x-1)] )
}

Here's an iterative definition of triangle:

p7proc (int)triangle_iterative { (int)x } {
        set (int)sum 0
        for {set (int)i 0}  ($i <= $x)  {incr i}  {
                incr sum $i
        }
        return $sum
}

Now here's an example with a vector of unicode characters. In P7 this type is named (uni*) . It's like the type char[] in Java.

pproc (uni*)to_lower { (uni*)x } {
    for {set (int)i 0} ($i < [len $x]) {incr i} {
        if ( 'A' <= $x($i) && $x($i) <= 'Z' ) {
            set x($i) ($x($i) - 'A' + 'a')
        }
    }
    return $x
}

The next example defines a p7class named Node, which has two fields, left and right. Then ParentheTcl functions cons, car, & cdr simulate Lisp operations with the Node class to construct a new Node get the left part, or get the right part.

p7class Node { (tcl)left (Node)right }

p7proc (Node)cons { (tcl)a (Node)b } {
    set (Node)z [new Node]
    set z(left) $a
    set z(right) $b
    return $z
}
p7proc (tcl)car { (Node)x } { return $x(left) }

p7proc (Node)cdr { (Node)x } { return $x(right) }

p7proc (Node)append_item { (Node)list (tcl)item } {
    if ($list==null) { return [cons $item null] }
    cons [car $list] [append_item [cdr $list] $item]
}
p7proc (Node)reverse { (Node)x } {
    if ($x==null) {return $x}
    append_item [reverse [cdr $x]] [car $x]
}

See more sample programs here.

Reference Manual

Work In Progress: see http://yak.net/repos/parenthetcl/_darcs/current/doc/ for a snapshot.

Philosophy

ParentheTcl is a 90/10 Language. it only needs to have the 10% of language features that cover 90% of the problems in our target applications. It does not need all the features of a complete modern language; all of Tcl is still there for the rest.

Other Completed Features

Future Directions

Not in any particular order of priority, just some ideas...

Download

Beta quality. All "make test" tests should work. Tested only on Fedora Core with i386.

Get tarballs from http://yak.net/repos/ or use "darcs get" from http://yak.net/repos/parenthetcl/

Instructions:

Run "sh configure --help", then configure and make. Use tcl8.4.4 or later.

Reports:

Works with Ubuntu 64-bit LiveCD:

UPDATES

  • New: type (dict), for (tcl)-to-(tcl) hashtables
  • New: lambda expressions
  • New: oo7, an object-oriented class system for Tcl, written in ParentheTcl
  • http://yak.net/repos/parenthetcl-0.6.2.tar.gz

    [ Sorry, all guestbooks disabled temporarily due to rampant spam :(   ]
  • parenthetcl-0.6.4.tar.gz
  • (last modified 2013-11-21)       [Login]
    This page is referenced by the following pages:
    ParentheTcl: Parenthetical