You are here

Tmac - Tcl macro processor package 1.0

admin의 아바타
첨부 파일파일 크기
Package icon tmac1.0.zip56.83 KB
Binary Data tmac1.0.tar.gz60 KB

홈페이지 :

Tmac는 Tcl에서 매크로 기능을 제공하는 패키지 입니다.
순수 Tcl로 작성되었으며, Tcl 8.4.0이상을 지원합니다.

Tmac is a macro facility for Tcl. It lets developers customize their use of Tcl so that they can write more concise code depending on specific needs in the application. Since Tmac processing takes place before the Tcl code is parsed, there is generally no runtime penalty for macros. In fact, macros could easily speed up code by reducing the number of evals, by ensuring that all expr arguments are braced, and generally making it easier to streamline or follow best practices because they can be embedded in macros and reused.

# Making a customized string range - define macro "srange"
MAC-BLOCK sfield s fs fl {[string range @s @fs [expr {@<a href="mailto:fs+@fl">fs+@fl</a>-1}] ]}

set s "abc_0555_YXZ"
set fstart 4
set flength 4

# Invoke the macro:

set field1 <:sfield $s $fstart $flength:>

# The equivalent Tcl Code

set fieldx [string range $s $fstart [expr {$fstart+$flength-1}]]