'}' in a library function?

May 20, 2008
Syracuse, NY, USA
I think I followed the rules by putting the function-terminating '}' on a line by itself. But LIBRARY doesn't seem to like '}' elsewhere.
g:\tc23\library> head /n3 iprocessline.txt
rv {
echo {foo}

g:\tc23\library> library /r iprocessline.txt /u

g:\tc23\library> library /f rv
rv {



Staff member
May 14, 2008
If the last character on a line is a }, it is interpreted as the end of the function definition.

The beta testers complained that they didn't (always) want to have a line with just a } to terminate a function; they wanted to append it to the last line of the definition.
May 20, 2008
Syracuse, NY, USA
If the last character on a line is a }, it is interpreted as the end of the function definition.

The beta testers complained that they didn't (always) want to have a line with just a } to terminate a function; they wanted to append it to the last line of the definition.
Putting the function-terminating '}' on a line by itself is very reasonable, and arguing against that seems a bit petty. I don't recall such a discussion and after looking for 30 minutes, couldn't find it. Can you direct me to it?

You probably should have said "last non-whitespace character on a line". Adding whitespace after "echo {foo}" doesn't help.

The way it is seems somewhat less than ideal. I prefer the behavior described in the help. In any event, the help and real life should agree.
Mar 18, 2010
Having to "waste" an extra line to meet TCC's syntax requirement is a miniscule sacrifice compared to having obscure failures show up triggered by the library function content, such Vince found.

Most everybody (except LISP lovers) puts closing constructs at the same indentation as the matching opening construct, so putting the closing brace on its own line is clearer anyway.

The present behavior is clearly quirky, and to avoid it is hard, as Vince demonstrated. Documenting the quirky behavior will take more mental space than would be needed if the closing brace had to stand alone.

I suppose the present behavior means that text/endtext and functions are going to interact strangely, since there is no good way to escape anything inside of a text/endtext block. And here I have imagined text/endtext as a tool for writing brace-containing, multi-line code. I guess it's good for that, but probably not in library-defined functions.
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly How to? Get name of current LIBRARY function? Support 4
Joe Caverly No blank line in TEXT...ENDTEXT in a LIBRARY function Support 8
cgunhouse Ctrl-C from within a library function Support 6
Joe Caverly Debugging a LIBRARY function Support 10
Joe Caverly LIBRARY /F in v28 Support 0
Joe Caverly LIBRARY and Pipes Support 2
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
vefatica Continued lines (^) in a library routine? Support 5
vefatica LIBRARY and file name completion? Support 4
vefatica Library functions and line continuations? Support 4
Joe Caverly @NAME supports library functions Support 2
Joe Caverly Update ENDLOCAL to include LIBRARY Support 0
J Documentation Make tcc great again - what's the benefit of LIBRARY? Support 6
vefatica Documentation Function parameters Support 0
Jay Sage Documentation Function @DRIVE Missing in Help Lists Support 0
x13 WeekNum function? Support 3
C email[string] function Support 10
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
Dick Johnson Using the @instr function Support 5
D Can the argument to RETURN be a function expansion? Support 3
J Trouble with @full[] function. Support 3
Fross Quick Function Question Support 17
vefatica Quoting @Function parameters? Support 0
Steve Pitts Documentation @CAPI function summary Support 0
x13 %x$ in function Support 3
thorntonpg @eval function, interesting results any explanation? Support 3
x13 Function to get interface user-defined name? Support 10
vefatica Fixed Help @FUNCTION, missing paragraph Support 8
Mordachai Variable followed by function constantly failing... Support 5
nickles Call a complex function Support 13
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
R Function #IDOW returns only 2 characters Support 10
T scrput `` in alias or function Support 2
S International characters - TYPE vs %@LINE function Support 5
JohnQSmith WAD @REPEAT function Support 15
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
R In addition to ALIAS /Z and FUNCTION /Z, HISTORY /Z? Support 1
A pdir function usage Support 3
nikbackm FUNCTION with variable number of arguments Support 17
S %@REGQUERY function Support 1
Dan Glynhampton Documentation v15 help: Error on @TRIMALL function page Support 0
M Why doesn't this @Field function work? Support 0
fpefpe How to? user function Support 1
M Why is this function getting these results in these circumstances? Support 6
A WAD function return values with parentheses prevent evaluation of additional functions Support 31
M Just an out-of-curiosity question the List command vs. the @Lines function... Support 13
M How to? Just verification for what I think I know regarding "Function"... Support 4
Frank How to? need help with "function" Support 10
Joe Caverly How to? Function Key With INPUT Support 5
M How to? "Function" and "%[xxx]" Support 7

Similar threads