|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
Re qzwqzw
“记得曾经有人说过
它不过是一个无效的标签而已
注释只是它的副作用”
已经去掉了关于::的解释。
“因为cmd检查到冒号后有无效字符时直接忽略处理”
测试发现无所谓“无效”字符,可以是任何字符。
“相反数的说法容易让人误解”
已经修改过来了,先前这样写是让别人容易理解写,但是没有描述其具体的本质作用。
“^是按位异或”
已经修改。
btw,想问一下,异或 和 异有什么区别呢?
Re qzwqzw
"Remember someone once said
It's just a useless tag
Comments are just its side effect"
The explanation about :: has been removed.
"Because when cmd detects an invalid character after a colon, it directly ignores the processing"
Tests show it doesn't matter if the "invalid" character is any character.
"The statement about the opposite number is easy to be misunderstood"
It has been revised. Previously, it was written like this to make it easy for others to understand, but it didn't describe its specific essential function.
"^ is bitwise XOR"
Revised.
btw, I want to ask, what's the difference between XOR and "different"?
|
|
2007-5-31 10:08 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
测试发现无所谓“无效”字符,可以是任何字符。
-----------------------
:字符后当然可以是任何字符
因为无效字符cmd是忽略解释的
怎么可以知道这一点呢?
定制一个这样的标签 ::errorlabel
然后试着goto ::errorlabel
如果能goto到说明是有效的
否则是无效的
我们的注释自然是需要无效的标签标记
否则有可能跟系统定义的或者我们定义的标签冲突
关于::的由来其实早有渊源
起初是因为 ms-dos 给的 rem 命令后无法直接使用管道和重定向符号
而且如果不echo off它的代码就会在运行时回显
所以就有人钻了这么一个漏子而已
从这几点也可以看出
因为少了许多预处理的过程
使用::的效率要高于rem
后来虽然cmd中虽然对rem作了许多改进
但::因为简单易用并且接近高级语言的注释标记
所以已经流传开来
----------------------------------
我没有见过“按位异”的说法
“异或”的意思是 不同于“或”
因为或的规则是
0|0=0
0|1=1
1|0=1
1|1=1
而异或稍有变化
0^0=0
0^1=1
1^0=1
1^1=0
Last edited by qzwqzw on 2007-5-31 at 12:46 PM ]
It is found in testing that there is no so-called "invalid" character, and it can be any character.
-----------------------
:Of course, any character can follow the colon character
Because the cmd ignores the interpretation of invalid characters
How can we know this?
Define such a label ::errorlabel
Then try to goto ::errorlabel
If it can goto there, it means it is valid
Otherwise, it is invalid
Our comments naturally need to be marked with invalid labels
Otherwise, there may be conflicts with system-defined or our defined labels
The origin of :: actually has a long history
At first, it was because the rem command given by ms-dos could not directly use pipe and redirect symbols
And if you don't echo off, its code will be echoed during runtime
So someone took such a loophole
From these points, it can also be seen
Because there are many fewer preprocessing processes
The efficiency of using :: is higher than that of rem
Later, although many improvements were made to rem in cmd
But :: has spread because it is simple and easy to use and close to the comment mark of high-level languages
----------------------------------
I have never seen the term "bitwise XOR"
"XOR" means different from "OR"
Because the rule of OR is
0|0=0
0|1=1
1|0=1
1|1=1
And XOR is slightly different
0^0=0
0^1=1
1^0=1
1^1=0
Last edited by qzwqzw on 2007-5-31 at 12:46 PM ]
|
|
2007-5-31 12:42 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
多谢qzwqzw释疑。。
我说的:后面可以是任何字符,是指在做注释时,没有被调用的标签都可以做注释。
关于goto ::errorlabel这样一个标签,无论如何也goto不到,所以用::就比较合理了。
个人理解是因为在goto里面,如果标签里面有:号,那么这个分号只是一个分隔符而已,类似的还有几个,比如 , : ( ,在它们后面的字符就不作解释了。
如果 goto ::errorlabel ,那么批处理就认为是在goto一个空的标签,而空的标签是无法构造和让goto起作用的。
示例:(为了可以返回用call代替了goto)
@echo off
call :hello;bat
call :hello,vbs
call :hello:asm
call :hello(java
call ::hello
pause&goto :eof
:hello
echo This is one line.
goto :eof
:
echo This is other line.
Last edited by lxmxn on 2007-5-31 at 08:15 PM ]
Thanks a lot for qzwqzw's clarification..
What I said: The following can be any character, which means that when making comments, all tags that are not called can be used as comments.
Regarding a label like goto ::errorlabel, it can never be reached by goto, so using :: is relatively reasonable.
Personal understanding is that because in goto, if there is a : in the label, then this colon is just a separator. There are several similar ones, such as,, :, (, and the characters after them are not interpreted.
If goto ::errorlabel, then the batch processing will think that it is going to a blank label, and a blank label cannot be constructed and make goto work.
Example: (call is used instead of goto for the sake of being able to return)
@echo off
call :hello;bat
call :hello,vbs
call :hello:asm
call :hello(java
call ::hello
pause&goto :eof
:hello
echo This is one line.
goto :eof
:
echo This is other line.
Last edited by lxmxn on 2007-5-31 at 08:15 PM ]
|
|
2007-5-31 15:10 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
你对::的理解比我更确切
-----------------------------------------------------------------------
从预处理的角度分析
在goto和:label的预处理过程中
所有的特殊字符全部被转义或过滤
而goto ::label被预处理成了个 goto 空标签 label
label被goto忽略
因为无法为空标签设置跳转标记
所以::label不会起作用
-----------------------------------------------------------------------
“:是无效字符”更确切的说是“:等字符是用于界定token的分隔符(或者界定符)”
“cmd忽略无效标签”更确切的说是“goto忽略了空标签后的多余参数”
Last edited by qzwqzw on 2007-6-2 at 11:51 PM ]
Your understanding of :: is more accurate than mine.
-----------------------------------------------------------------------
Analysis from the perspective of preprocessing
In the preprocessing process of goto and :label,
All special characters are all escaped or filtered.
And goto ::label is preprocessed into a goto empty label label.
The label is ignored by goto.
Because an empty label cannot be set with a jump mark,
So ::label will not work.
-----------------------------------------------------------------------
"Semicolon is an invalid character" is more accurately "Semicolons and other characters are delimiters (or delimiters) used to define tokens".
"The cmd ignores invalid labels" is more accurately "goto ignores the extra parameters after the empty label".
Last edited by qzwqzw on 2007-6-2 at 11:51 PM ]
|
|
2007-5-31 19:08 |
|
|
scriptor
银牌会员
    
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
Originally posted by lxmxn at 2007-5-30 22:24:
Re scriptor:
嗯,多谢补充,我再添加进去。
根据 qzwqze 15楼的解释,已经取消了关于::的注释说明。
Last edited by lxmxn on 2007-5-31 at 10:17 AM ]
呵呵
没事!
15#
看来我知道的太少啊
惭愧 。
Originally posted by lxmxn at 2007-5-30 22:24:
Re scriptor:
Well, thanks for the supplement, I'll add it in.
According to the explanation by qzwqze on floor 15, the annotation about :: has been removed.
Last edited by lxmxn on 2007-5-31 at 10:17 AM ]
Hehe
It's okay!
Floor 15#
It seems I know too little
Ashamed.
|
|
2007-6-1 00:59 |
|
|
dinfli
初级用户
 
积分 180
发帖 82
注册 2007-1-11
状态 离线
|
|
2007-6-1 01:50 |
|
|
qinbuer
高级用户
    我思故我在
积分 512
发帖 228
注册 2007-1-21
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
少的就是它!
What's missing is it!
|

我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。 |
|
2007-6-1 02:16 |
|
|
wj12390
新手上路

积分 18
发帖 9
注册 2007-6-1
状态 离线
|
|
2007-6-4 15:08 |
|
|
Li103Z
初级用户
 
积分 70
发帖 38
注册 2007-5-23
状态 离线
|
|
2007-6-7 11:11 |
|
|
haiou327
高级用户
    DOS时空
积分 713
发帖 348
注册 2007-2-10
状态 离线
|
|
2007-6-22 01:22 |
|
|
wgx1688
初级用户
 
积分 60
发帖 34
注册 2007-4-24
状态 离线
|
|
2007-6-24 12:14 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
%=
① 在set /a中的二元运算符。例如set /a a"%="b表示将a除以b的余数赋值给a。
【 %= 两边加上 " 防止 % 被转义,下同。】
--------------------------------------------------------------------------
【】里的说明有问题
cmd的命令行预处理中
%的解析早于"
也就是说%的优先级高于"
所以引号对不能取消%的转义
这里应该说明的是
在命令行中用单个%没有问题
set /a a%=b
在批处理中需要使用双%
set /a a%%=b
%=
① Binary operators in set /a. For example, set /a a"%="b means assigning the remainder of a divided by b to a.
--------------------------------------------------------------------------
The description in is incorrect.
In the command line preprocessing of cmd,
The parsing of % occurs earlier than ".
That is, the priority of % is higher than ".
So the quotation marks cannot cancel the escape of %.
Here it should be explained that
It is okay to use a single % in the command line
set /a a%=b
In a batch script, double % need to be used
set /a a%%=b
|
|
2007-6-26 11:11 |
|
|
wl48693752
初级用户
 
积分 24
发帖 9
注册 2007-6-13
状态 离线
|
|
2007-6-26 11:49 |
|
|
wl48693752
初级用户
 
积分 24
发帖 9
注册 2007-6-13
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
能有份这样汇集批处理知识的帖子或者文章就好了
It would be great to have a post or article that gathers batch processing knowledge like this.
|
|
2007-6-26 13:01 |
|
|
Lick
初级用户
 
积分 62
发帖 28
注册 2006-3-14
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
多谢分享了,收藏了!
Thanks for sharing, I've bookmarked it!
|
|
2007-6-26 13:12 |
|