Mirror of
forum.nim-lang.org
index
8105 :: What is the purpose of do {} while (false) in JavaScript output?
[2021-06-11T09:17:36+02:00]
View Orginal
xigoi
(orginal)
[2021-06-11T09:17:36+02:00]
view original
When compiling to JavaScript, I noticed a lot of
do {} while (false)
in the output. So I got curious, what is the point of these? I know the construct is sometimes used in C macros to avoid weird issues, but I've never seen it used in JavaScript.
bung
(orginal)
[2021-06-11T09:30:42+02:00]
view original
I guess just because the compiler transform loop as do while, so the generated code whether c or js just match this statement.
Araq
(orginal)
[2021-06-11T10:40:41+02:00]
view original
It's done for
block
so that we have a label that can be used for
break
.