Sugar

News

0.1 version released. This is the first real release in form of a Tcl package. See the download section for the download URL.

Introduction

Sugar is a macro system for the Tcl programming language, with a design very similar to Lisp macros.

This document will try to explain what Sugar macros are, how they can be applied, and why I think they improve the Tcl language.

Every time I refer to the term macro in this document, I mean a Sugar Tcl macro if not better specified.

Note that the idea of a macro system for Tcl is not new, but as far as I know, there is no implementation that is comparable with Sugar in terms of usage and design principles. Something of similar in the spirit, is the Tmac - a Tcl macro processor package, but it works by pattern matching and substitution, requires the user to use a special syntax, does not guarantee the expansion to happen only where actually a command can be called, and can't be used to add arbitrary new syntax to Tcl (syntax macros feature of Sugar), nor complex code transformation (see for example the transformer macro to optimize tail calls in this document).

Programmer API

The following sections will explain the basic Sugar API with some detail, but it's worth to say now that macro expansion happens when the proc command is called. Actually Sugar is a wrapper for proc, an API to write source code transformations, and some command to register this transformations in the modified version of proc.

Sections

You may also want to check the Sugar macros collection page.

Authors

I'm (Salvatore Sanfilippo) currently the only author of Sugar.

Download

You can get the latest version of Sugar from http://www.hping.org/tclsbignum/sugar-0.1.tar.gz

Also, Sugar is available in Debian and Debian-derived Linux distributions (such as Ubuntu) as tcl-sugar.

If you have suggestions, bugfixes or API changes requests, please drop me an email at antirez at invece dot org.

See also run.

Disambiguation

SUGAR is also an open source CRM (Customer Relationship Management) application.