summaryrefslogtreecommitdiffstats
path: root/generic/tclCompCmdsGR.c
diff options
context:
space:
mode:
authorferrieux <ferrieux@users.sourceforge.net>2014-08-01 16:34:11 (GMT)
committerferrieux <ferrieux@users.sourceforge.net>2014-08-01 16:34:11 (GMT)
commit28c803e0587a6f34716420ed9a3e63dea93b2255 (patch)
treeb111aed5eb37ab357fc42b097745869da90c996a /generic/tclCompCmdsGR.c
parent5d6c006a2ce1195737c5d8ce05d7b53e41389005 (diff)
downloadtcl-tip429_only_id.zip
tcl-tip429_only_id.tar.gz
tcl-tip429_only_id.tar.bz2
Recognize that "id" is the K combinator in disguise. Rename it as "K" and extend its semantics accordingly.tip429_only_id
Diffstat (limited to 'generic/tclCompCmdsGR.c')
-rw-r--r--generic/tclCompCmdsGR.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c
index 620c2ff..345c19e 100644
--- a/generic/tclCompCmdsGR.c
+++ b/generic/tclCompCmdsGR.c
@@ -163,23 +163,23 @@ TclCompileGlobalCmd(
/*
*----------------------------------------------------------------------
*
- * TclCompileIdCmd --
+ * TclCompileKCmd --
*
- * Procedure called to compile the "id" command.
+ * Procedure called to compile the "K" combinator command.
*
* Results:
* Returns TCL_OK for a successful compile. Returns TCL_ERROR to defer
* evaluation to runtime.
*
* Side effects:
- * Instructions are added to envPtr to execute the "id" command at
+ * Instructions are added to envPtr to execute the "K" command at
* runtime.
*
*----------------------------------------------------------------------
*/
int
-TclCompileIdCmd(
+TclCompileKCmd(
Tcl_Interp *interp, /* Used for error reporting. */
Tcl_Parse *parsePtr, /* Points to a parse structure for the command
* created by Tcl_ParseCommand. */
@@ -188,24 +188,25 @@ TclCompileIdCmd(
CompileEnv *envPtr) /* Holds resulting instructions. */
{
/*
- * General syntax: [id value]
+ * General syntax: [K ?value ...?]
*/
int numWords = parsePtr->numWords;
Tcl_Token *wordTokenPtr = TokenAfter(parsePtr->tokenPtr);
DefineLineInformation; /* TIP #280 */
- if (numWords!=2) {
- /*
- * Wrong #args. Clear the error message,
- * and report back to the compiler that this must be interpreted at
- * runtime.
- */
+ if (numWords>=2) {
+ int i;
- Tcl_ResetResult(interp);
- return TCL_ERROR;
+ for (i = 1; i < numWords; i++) {
+ CompileWord(envPtr, wordTokenPtr, interp, i);
+ wordTokenPtr = TokenAfter(wordTokenPtr);
+ if (i>1) {
+ TclEmitOpcode(INST_POP, envPtr);
+ }
+ }
+ } else {
+ PushStringLiteral(envPtr, "");
}
-
- CompileWord(envPtr, wordTokenPtr, interp, numWords-1);
return TCL_OK;
}