Comments (14)
Just tested this with the spec interpreter:
(module
(export "f" $f)
(func $f
(loop $foo $foo
(block $foo
(block $foo
(br $foo))))
))
No error. It seems that the spec interpreter just uses the first label it finds.
from spec.
What about:
(loop $foo $foo
(br $foo))
Is this a break or continue?
from spec.
If this is the behavior we want, then I guess we should spec the label search order. I feel that relying on search order is kind of error prone.
from spec.
@mbebenita The loop block label should be the outer label, so it should see the loop repeat label. The binary encoding has no labels here, but you are right that the order should be specified.
from spec.
@JSStats I was under the impression that the loop blocks are just blocks with an additional label. So it effectively has two labels, and they are both outer labels as far as the (br $foo)
is concerned. Am I missing something here?
(block $foo
(br $foo) ;; break
)
(loop $foo %bar
(br $foo) ;; continue
(br $bar) ;; break
)
(loop $foo %foo
(br $foo) ;; continue or break?
)
from spec.
I'm in favor of disallowing the ambiguous cases (1 or 2 in the first comment).
from spec.
(loop $foo $bar ...)
is sugar for
(block $foo (loop $bar ...))
See https://github.com/WebAssembly/spec/blob/master/ml-proto/README.md#s-expression-syntax.
Testing this in ml-proto:
(module
(export "f" $f)
(func $f
(loop $foo $foo
(br $foo))
))
(invoke "f")
is an infinite loop.
So the search order is from "outward".
from spec.
@kripken option 2 is consistent with JS semantics, so I'd favor that as well.
from spec.
@binji ah, I see, that makes sense.
from spec.
@binji Not sure if 'outward' is meaningful. Perhaps note labels are a lexical binding, a stack, and that the lookup chooses the first in the stack, so an inner binding shadows an outer binding. But it's just for the spec wast and perhaps people would rather not have such hazards in tests etc.
from spec.
Labels have standard lexical scoping behaviour. That is, they scope over the labelled expression, and can be shadowed within their scope. The loop
case is defined by its desugaring.
We could disallow shadowing, but I don't see a strong reason for that. Everything regarding names is not part of the "official" spec semantics anyway.
from spec.
We could disallow shadowing, but I don't see a strong reason for that.
What is the advantage? From my perspective this has disadvantages because it is unusual and mostly creates an opportunity for confusion.
Everything regarding names is not part of the "official" spec semantics anyway.
This doesn't match our design history, and it feels like a semantic trick. In the context of tableswitch and a bunch of cases, the best way to describe the numbering of the br
targets for the cases would be labels where the names are arbitrary compiler-assigned numbers.
from spec.
On 21 January 2016 at 18:14, Katelyn Gadd [email protected] wrote:
We could disallow shadowing, but I don't see a strong reason for that.
What is the advantage? From my perspective this has disadvantages because
it is unusual and mostly creates an opportunity for confusion.
Allowing shadowing ensures locality and compositionality: without it, you
cannot syntactically insert a piece of code into another piece and expect
it to keep working. At least in general language design, that is a very
useful modularity property. Not saying it's super-important here, but I
also don't see the opposite.
Everything regarding names is not part of the "official" spec semantics
anyway.
This doesn't match our design history,
Not sure why you're saying that. The AST semantics never had names, AFAIR.
and it feels like a semantic trick. In the context of tableswitch and a
bunch of cases, the best way to describe the numbering of the br targets
for the cases would be labels where the names are arbitrary
compiler-assigned numbers.—
Reply to this email directly or view it on GitHub
#210 (comment).
from spec.
@rossberg-chromium 'locality and compositionality' seem important for a usable source code. FYI For (module (func $f1 (block $l1 (block $l1 (nop)))))
sexp-wasm gives 'redefinition of label "$l1"'!
from spec.
Related Issues (20)
- [interpreter] Source locations are broken since menhir switch HOT 2
- SIMD test optimization? HOT 3
- [core] SIMD Compare instructions link to the wrong "execution"/"validation" sections HOT 1
- Add a note indicating that section ids and section ordering do not correspond HOT 2
- Missing ability to access built older versions of the WebAssembly specification in archivable form HOT 2
- [JS API] 'run a host function' and 'create a host function' don't consistently handle completion records HOT 1
- Wording of README in proposals directory is misleading. HOT 6
- Test extreme alignments HOT 2
- Tests seem to cause side effects that other tests depend on HOT 2
- A question about max table size HOT 5
- Time to delete the old `master` branches? HOT 5
- Missing LICENSE file in the document directory HOT 1
- A question about the order of exports HOT 4
- [bikeshed] Some potential issues in js-api spec HOT 1
- [js-api] Bikeshed issues on wasm-3.0 branch HOT 2
- Fix CSS so the specification shows on narrow viewports without horizontal scrolling. HOT 7
- Possibly incorrect encoding in WAST->JS conversion for elem.wast in wasm-3.0 branch HOT 3
- [reference-types] behavior of out-of-bound in table.fill HOT 1
- Change direction in wording around stack unwinding HOT 2
- a
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec.