|
Top Document: comp.lang.tcl Frequently Asked Questions (March 07, 2005) (1/6) Previous Document: -III- Do these packages run on my machine? Next Document: -V- What training material is available? See reader questions & answers on this topic! - Help others by sharing your knowledge A. Shell There are a number of interfaces which are shell-like. The first is tclsh, which comes as a sample program implementing a Tcl interpreter as a part of the Tcl distribution. Another is wish, which is a shell-like interface that is a part of the Tk package. Many of the other extensions also build interpreters as well. The tclX extension is an example - it builds an interpreter called tcl as well as one called wishx. B. C++ There is a package called Objectify which can be used to assist one in turning C++ classes into Tcl object types. If you wish to use C++ with Tcl then you must have your main() in a source file that is compiled with a C++ compiler; this will ensure that the necessary C++ pre-main initialization code is executed. You can call tcl and tk routines (or other C code) routines from C++ provided that the function prototypes avoid C++ name mangling by using the C++ linkage specification : extern "C" ... prototype ... Fortunately, tcl.h and tk.h will provide these specifications when compiled with a C++ compiler and so you can just use them directly. You can construct your main using normal tcl and tk routines, or use tkMain.c and tkAppInit.c with minor modifications. Ken Yap's patch, obtainable from <URL: ftp://ftp.procplace.com/pub/tcl/alcatel/extensions/tk3.6forC++.patch.gz >, is a patch that allows tk 3.6 main.c and other extension routines to be compiled with a C++ compiler. Thanks to Ken Yap <URL: mailto:ken@syd.dit.csiro.au > for this code. C++ functions and static class member functions can be used to create Tcl command using Tcl_CreateCommand in the normal way. Non-static member functions cannot be used so simply, Tcl would have to supply a "this" pointer. SWIG <URL: http://www.swig.org/ > is another great resource for using C++ and Tcl. To quote the author: > SWIG is a code development tool created to solve real problems and > make C/C++ programming more enjoyable. Simply stated, SWIG > allows you to integrate common scripting languages such as Tcl, > Perl, Python, and Guile with programs containing collections of > functions written in C or C++. By using an interpreted scripting > language with a C program, you can do a number of cool things like: > Build a powerful interface. > Rapidly prototype new features. > Interactively debug and test your code. > Develop a graphical user interface. > Build C/C++ modules for scripting language applications. > Save lots of time--allowing you to work on the real problem. > Impress your friends. One user notes: > To contrast SWIG with Objectify - SWIG has you prepare a small interface > file that specifies what functions are to be wrapped, rather than adding > macros to your original header file. It also works with C, as well as > C++. C. Modula-3 Norman Ramsey <URL: mailto:elan.uucp!nr > says: A long time back, Eric Muller posted a Modula-3 interface to the C Tcl library. I wrote down a Modula-3/Tcl interface that used Modula-3 types rather than C types, and that used objects to build closures for commands. I wrote part of the implementation but never finished it. I have mailed copies to <URL: mailto:carroll@udel.edu >, who asked the question, and I will post them if there seems to be general interest. Also, there is an interface between Tk and Modula-3 that is a part of the Modula-3 archives on <URL: ftp://gatekeeper.dec.com/ >, and Tcl-DP and Modula-3 have been merged. D. Eiffel <URL: mailto:stephan@cs.tu-berlin.de > (Stephan Herrmann) says: ... [the tclish package provides] the marriage of two very different principles by means of combining two programming languages into a hybrid program architecture. There are three classes for the user - tcl interpretor, tk application, and tk window. See <URL: ftp://hepunx.rl.ac.uk/pub/eiffel/ > for details. E. Ada <URL: mailto:dennis@dennis.cs.colorado.edu > (Dennis Heimbigner) introduced an adatcl package which gives Ada programmers access to Tcl interpreters. (See "part4") for details of the package. F. Perl In the past, efforts by Dov Grobgeld <URL: mailto:dov@menora.weizmann.ac.il > and Guenther Schreiner <URL: mailto:guenther@ira.uka.de > were made to develop at least 2 Perl 4 to Tcl/Tk interfaces. More effort has occured in the Perl 5 environment, where an extension to allow Perl 5 to directly access the Tcl C API, as well as an extension to allow the ability to do Tk programming without a Tcl interpreter involved at all are available. These packages can be ftp'd from the Comprehensive Perl Archive Network (CPAN) - a series of ftp sites which keep the latest and greatest archives of Perl code in sync. See <URL: http://www.perl.com/perl/CPAN/CPAN.html > for a pointer to CPAN, and follow the links to find the Tcl related Perl packages. G. Prolog The package ProTcl is an interface between Prolog and Tcl/Tk. It works best with ECLiPSe, but the foreign interface of SICStus and Quintus is also provided. The interface is dynamically loaded into a Prolog process and it gives access to Tcl commands and to handling Tk events. It is also possible to call Prolog from Tcl, handle Tk events in Prolog and to pass Prolog variables back to Tcl. See <URL: http://www.ecrc.de/eclipse/html/protcl.html > for more details. H. Other A module for Python based on Tk is available - more details are available in <URL: news:comp.lang.python > on this front. Tk bindings for the Dylan language are being shipped as a part of CMU's Mindy compiler for Dylan. The Sather language also has a set of classes to bind in Tk/Tcl. Duncan Sinclair <URL: mailto:sinclair@dcs.gla.ac.uk > has details of a hack into wish.c some hooks for a Tk to any language system, and has been using it for communication with functional languages such as Haskell and Lazy ML. A paper, plus sample code, was available by ftp from <URL: ftp://ftp.dcs.gla.ac.uk/pub/glasgow-fp/authors/Duncan_Sinclair/ >. Unfortunately I've been unable to confirm this is still available. The InterLanguage Unification project is a system that promotes software interoperability via interfaces. It has the ability to allow Common Lisp, ANSI C, C++, Modula 3 to interact and plans to add Python, Tcl, and GNU Emacs-Lisp shortly. Of course the Wafe application environment is designed to make it easier to write GUI applications from within several languages using Tk as a basis. There are several interfaces to allow one to interface with SQL though some are specific to a database such as Oracle. There is an interpreter for Silicon Graphics machines for SGI's GL language. There is an interface to WOOL. The GNU language Guile not only has a Scheme backend, but a Tcl one as well. There are at least two interfaces to Tcl for Java. There is a Caml Light interface to Tcl/Tk. There is a commercial product which provides an interface between Objective C and Tcl. There is an interface between Oz and Tcl/Tk. There is a subset of Modula-3 with a Tk binding. There is at least one interface between Scheme and Tk. There is a binding in Gopher for Tcl/Tk. For Java, there is Jacl (a re-implementation of a good part of Tcl in Java classes) and TclBlend (a Tcl extension allowing a Tcl programmer to use Java classes as if they were Tcl commands). For more details on the above efforts, as well as other languages, see <URL: http://purl.org/tcl/wiki/TclAndOtherLanguages > and (see also "part4"). User Contributions:Top Document: comp.lang.tcl Frequently Asked Questions (March 07, 2005) (1/6) Previous Document: -III- Do these packages run on my machine? Next Document: -V- What training material is available? Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Single Page [ Usenet FAQs | Web FAQs | Documents | RFC Index ] Send corrections/additions to the FAQ Maintainer: lvirden@yahoo.com (Larry W. Virden)
Last Update March 27 2014 @ 02:12 PM
|

Comment about this article, ask questions, or add new information about this topic: