tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
tclsh extra2.test 11
tclsh extra2.test 2!! nothing !!
tclsh extra2.test 399
→ ha… ha… ha…
On Monday, August 29, 2022 at 8:37:51 AM UTC+2, aotto wrote:
tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
tclsh extra2.test 11
tclsh extra2.test 2!! nothing !!
tclsh extra2.test 399
→ ha… ha… ha…
That is not a bug. Tcl works as expected. But the expectation varies: comments are _not_ parsed first ...
Your 2nd argument to [if], i.e. the first code block, ends just before elseif, because of rule #6 of the dodekalogue.
Within that code block, you have commented out the last line (that is empty anyway).
Inside the branch { $num == 2 }, all non-empty lines are commented out.
A few notes:
* [if] and friends are ordinary commands in Tcl; you can even override them (but be warned: don't!).
* Tcl comments need not be the first non-space character of a line (but the first character of the first word when Tcl expects a command).
* I use [if 0 { ... }] to comment out code blocks temporarily. Still, there is no true inline comment like /* ... */ in C.
* The behavior does _not_ depend on using $argv.
* Tcl has a switch command.
On 29.08.22 09:06, heinrichmartin wrote:
On Monday, August 29, 2022 at 8:37:51 AM UTC+2, aotto wrote:
tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
That is not a bug. Tcl works as expected. But the expectation
varies: comments are _not_ parsed first ...
Your 2nd argument to [if], i.e. the first code block, ends just
before elseif, because of rule #6 of the dodekalogue. Within that
code block, you have commented out the last line (that is empty
anyway). Inside the branch { $num == 2 }, all non-empty lines are
commented out.
declare a BUG to a FEATURE makes your programmer-live much more easy ;-)
On 29.08.22 09:06, heinrichmartin wrote:
On Monday, August 29, 2022 at 8:37:51 AM UTC+2, aotto wrote:
tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
tclsh extra2.test 11
tclsh extra2.test 2!! nothing !!
tclsh extra2.test 399
→ ha… ha… ha…
That is not a bug. Tcl works as expected. But the expectation varies:
comments are _not_ parsed first ...
Your 2nd argument to [if], i.e. the first code block, ends just before
elseif, because of rule #6 of the dodekalogue.
Within that code block, you have commented out the last line (that is
empty anyway).
Inside the branch { $num == 2 }, all non-empty lines are commented out.
A few notes:
* [if] and friends are ordinary commands in Tcl; you can even override
them (but be warned: don't!).
* Tcl comments need not be the first non-space character of a line
(but the first character of the first word when Tcl expects a command).
* I use [if 0 { ... }] to comment out code blocks temporarily. Still,
there is no true inline comment like /* ... */ in C.
* The behavior does _not_ depend on using $argv.
* Tcl has a switch command.
declare a BUG to a FEATURE makes your programmer-live much more easy ;-)
On 8/29/22 02:16, aotto1968 wrote:
On 29.08.22 09:06, heinrichmartin wrote:
On Monday, August 29, 2022 at 8:37:51 AM UTC+2, aotto wrote:
tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
tclsh extra2.test 11
tclsh extra2.test 2!! nothing !!
tclsh extra2.test 399
→ ha… ha… ha…
That is not a bug. Tcl works as expected. But the expectation varies: comments are _not_ parsed first ...
Your 2nd argument to [if], i.e. the first code block, ends just before elseif, because of rule #6 of the dodekalogue.
Within that code block, you have commented out the last line (that is empty anyway).
Inside the branch { $num == 2 }, all non-empty lines are commented out.
A few notes:
* [if] and friends are ordinary commands in Tcl; you can even override them (but be warned: don't!).
* Tcl comments need not be the first non-space character of a line (but the first character of the first word when Tcl
expects a command).
* I use [if 0 { ... }] to comment out code blocks temporarily. Still, there is no true inline comment like /* ... */ in C.
* The behavior does _not_ depend on using $argv.
* Tcl has a switch command.
declare a BUG to a FEATURE makes your programmer-live much more easy ;-)
This behavior is clearly defined in the rules of Tcl syntax -- may I strongly suggest you go back and read them until you
internalize them well enough to see why this is NOT A BUG.
Be honest, the TCL specification was "designed" to make the example
below NOT-A-BUG ?
I thing it is clear that 99.99% of all programmers in the world (with
and without TCL knowledge) will define this example below as a
DESIGN-BUG and the 0.000000000001% of all coders who require this "code-after-comment" feature are still not born ;-)
aotto1968 <aotto1968@t-online.de> wrote:
Be honest, the TCL specification was "designed" to make the example
below NOT-A-BUG ?
Not at all. The TCL specification documents how the TCL parser parses
TCL source code. The design of that parser was set out by John
Ousterhout circa 1988 when he designed TCL. The parser is deliberately simple because TCL, circa 1988, was intended to be a small extension
language to be incorporated into a larger project. What you term
"NOT-A-BUG" is just a direct consequence of that deliberately simple
parser.
I thing it is clear that 99.99% of all programmers in the world (with
and without TCL knowledge) will define this example below as a
DESIGN-BUG and the 0.000000000001% of all coders who require this
"code-after-comment" feature are still not born ;-)
99.99% of programmers will learn the rules of the language before
jumpinng to "that's a bug".
On 29.08.22 19:57, Rich wrote:
aotto1968 <aotto1968@t-online.de> wrote:
Be honest, the TCL specification was "designed" to make the example
below NOT-A-BUG ?
Not at all. The TCL specification documents how the TCL parser parses
TCL source code. The design of that parser was set out by John
Ousterhout circa 1988 when he designed TCL. The parser is deliberately
simple because TCL, circa 1988, was intended to be a small extension
language to be incorporated into a larger project. What you term
"NOT-A-BUG" is just a direct consequence of that deliberately simple
parser.
I thing it is clear that 99.99% of all programmers in the world (with
and without TCL knowledge) will define this example below as a
DESIGN-BUG and the 0.000000000001% of all coders who require this
"code-after-comment" feature are still not born ;-)
99.99% of programmers will learn the rules of the language before
jumpinng to "that's a bug".
You don't understand why I post this TCL-BUG.
I don't know of a single Tcl ide that can do this reliably.
You don't understand why I post this TCL-BUG.as someone else already suggested: I 'comment out' code by using an
It is not just the simple example-code it is also a "comment-out-block".
To comment out a code-block is widely used for testing, etc.
If you always have to count-the-{ and step deep into code-flaw-pitfall it is >not good.
mfg
On 29.08.22 19:57, Rich wrote:
aotto1968 <aotto1968@t-online.de> wrote:
Be honest, the TCL specification was "designed" to make the example
below NOT-A-BUG ?
Not at all. The TCL specification documents how the TCL parser parses
TCL source code. The design of that parser was set out by John
Ousterhout circa 1988 when he designed TCL. The parser is deliberately
simple because TCL, circa 1988, was intended to be a small extension
language to be incorporated into a larger project. What you term
"NOT-A-BUG" is just a direct consequence of that deliberately simple
parser.
I thing it is clear that 99.99% of all programmers in the world (with
and without TCL knowledge) will define this example below as a
DESIGN-BUG and the 0.000000000001% of all coders who require this
"code-after-comment" feature are still not born ;-)
99.99% of programmers will learn the rules of the language before
jumpinng to "that's a bug".
You don't understand why I post this TCL-BUG.
It is not just the simple example-code it is also a "comment-out-block".
To comment out a code-block is widely used for testing, etc.
If you always have to count-the-{ and step deep into code-flaw-pitfall it is not good.
Tcl's way of commenting is perhaps its main freak that has been
scared away most of potential Tclers. Those who are able to overcome
it have a chance to live in Tcl world long and happily. Others
leave.
https://wiki.tcl-lang.org/page/comment
Due to the way the TCL parser works, in this particular instance, a
"comment out block" using "#" characters does not work. Comment
characters in Tcl work differently than in Bash or other languages that
use # as a line comment character. They have worked this way in TCL
since circa 1988. They are not likely to change now, 34 or so years
later.
On 8/29/2022 1:05 PM, Rich wrote:
Due to the way the TCL parser works, in this particular instance, a
"comment out block" using "#" characters does not work. Comment
characters in Tcl work differently than in Bash or other languages that
use # as a line comment character. They have worked this way in TCL
since circa 1988. They are not likely to change now, 34 or so years
later.
True, however, the manual entry on rule 10 could be improved.
The problem here is with the clause:
... then the hash character and the characters that follow it, up through
the next newline, are treated as a comment and ignored.
At minimum, it could say, "up through the next newline or the end of
the script, whichever comes first". However, I doubt that new tcl programmers would fully appreciate the distinction.
et4 <tclnews@...> wrote:
On 8/29/2022 1:05 PM, Rich wrote:
It does require understanding a fair bit more of the overall context of
the other rules to fully recognize what it is describing.
True. Better might be to add a statement to the effect of: "comment recognition occurs after the brace processing of rule 6 has been
completed." But even something like that requires a fair amount of contextual understanding of the other rules of TCL to recognize the
real meaning that it is attempting to convey. There may not be any
good way to write something up without becoming a very wordy tome.
Am 31.08.22 um 18:18 schrieb aotto1968:
Hi,[....]
This are MY rules for the new TCL
Well then have fun implementing it and come back when it is ready.
Christian
Hi,
This are MY rules for the new TCL
And, please, don't use your abbreviation "mfg" in English (or
nearly:) audience, it can be misunderstood. Just speak and write it
in Deutsch.
Mit freundlichen Grüßen.
Hi,
This are MY rules for the new TCL
1) add a simple pre-processor to TCL like CPP for C and add all the missing features like "(real)-comment" to top of this this
pre-processor
2) after preprocessing the OLD-Tcl parser get always "valid" TCL code
2) to activate a NEW featur use the new "pragma ?feature?" command
3) every TCL-Source-File is read with *source* and source is able to analyze the *pragma* and chose the proper pre-processor
4) A *pragma* is only valid WITHIN the singe source-file currently read (ease mix OLD and NEW style code)
example add block-comment #* … *# :
---------------------------------------
pragma new-style-comment
lassign $argv num
if { $num == 1 } {
puts 1
#*
} elseif { $num == 2 } {
puts 2
*#
} else {
puts 99
}
--------------------------------------
this generate a valid tcl code like
---------------------------------------
pragma new-style-comment
lassign $argv num
if { $num == 1 } {
puts 1
(5 EMPTY lines, just to get the TCL-Line-Number counting right ;-)
} else {
puts 99
}
--------------------------------------
on top of the "pragma/pre-processor" a lot of usfull features can be added WITHOUT touching the TCL-Parser
On 8/31/22 14:38, Christian Gollwitzer wrote:
Am 31.08.22 um 18:18 schrieb aotto1968:+100,000
This are MY rules for the new TCLWell then have fun implementing it and come back when it is ready.
This are MY rules for the new TCL
Well then have fun implementing it and come back when it is ready.
mfg
Alex P <aplsimple@gmail.com> wrote in news:6fda5d67-0469-46be-866f-e4247db07b1cn@googlegroups.com:
And, please, don't use your abbreviation "mfg" in English (or
nearly:) audience, it can be misunderstood. Just speak and write it
in Deutsch.
Mit freundlichen Gr????en.
I have often wondered what "mfg" meant, now at last I know :-)
sbin/meta/tcl_MqC.tcl -lcMain from sbin/meta/tcl_MqC.tcl
just a limerick, core question in TCL:
how to comment-out a code block without lose(delete) and without create a huge hidden code bug?
if {$isPointer} {
if {$isOut} {
if {$isCast} {
lappend CALL_PRE_MAPPING $at $av NormalizePtrNull "${av}_val"
lappend CALL_POST_MAPPING $at $av NormalizePtr "${av}_val"
set av [Filter_Ref ${av}_val]
set isCast no
if 0 {
# \} elseif \{exists2($name,"force-error-return") && [lindex $::ATTRIBUTE($name,force-error-return) 1] eq $av} \{
# lappend CALL_PRE_MAPPING $at $av ErrorForceReturn "${av}_val"
# lappend CALL_POST_MAPPING $at $av ErrorForceReturn "${av}_val"
# continue
}
} else {
switch -regexp $at {
ME_BNP {
lappend CALL_POST_MAPPING $at $av ByteArray_Write "${av}_ptr"
lappend args [Filter_Out ${av}_ptr]; set av [Filter_Out ${av}_size]
}
default { set av [Filter_Out $av] }
}
}
...
how to comment-out a code block without lose(delete) and without create a huge hidden code bug?if 0 {
# \} elseif \{exists2($name,"force-error-return") && [lindex $::ATTRIBUTE($name,force-error-return) 1] eq $av} \{
# lappend CALL_PRE_MAPPING $at $av ErrorForceReturn "${av}_val"
# lappend CALL_POST_MAPPING $at $av ErrorForceReturn "${av}_val"
# continue
}
how to comment-out a code block without lose(delete) and without create a huge hidden code bug?
Hi, put code down in a "extra2.test" file and call it with :
tclsh extra2.test 1 or 2 or 3
===============================
lassign $argv num
if { $num == 1 } {
puts 1
# } elseif { $num == 2 } {
#
# puts 2
} else {
puts 99
}
=================================
tclsh extra2.test 11
tclsh extra2.test 2!! nothing !!
tclsh extra2.test 399
→ ha… ha… ha…
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 183:51:46 |
Calls: | 9,705 |
Files: | 13,737 |
Messages: | 6,179,583 |