Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006246OCamlOCaml generalpublic2013-11-26 05:382013-12-05 09:35
Reporterygrek 
Assigned Tofrisch 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version4.02.0+dev 
Summary0006246: `for _ = e1 to e2` syntax is not allowed
DescriptionWith the advent of the new warning 35 (unused for-loop index) it becomes natural to want this..
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010664)
gasche (developer)
2013-11-26 06:48

Makes perfect sense.
(0010665)
frisch (developer)
2013-11-26 14:44

You probably know it, but the warning can be silenced by using an identifier starting with "_". And "__" (double underscore) is such a valid identifier. But yes, indeed, it makes sense to allow "_" as for-loop index.

Users might expect that a context which allows both an identifier and _ would also support any pattern. Should we accept syntactically (and represent in the Parsetree) any pattern and reject those outside "_" and identifiers in the type-checker, or restrict the parser and Parsetree to only identifier and _ (represented as an "string loc option" in the Parsetree)?
(0010666)
gasche (developer)
2013-11-26 15:00

I think rejecting in the type-checker would be best.
(0010683)
doligez (administrator)
2013-11-30 22:56

I think accepting any pattern is just adding useless complexity to the compiler.

Also, why "string loc option" and not "string option loc" ?
(0010687)
frisch (developer)
2013-12-02 19:04

Commit 14330 on trunk. The parse accepts any pattern, and the type-checker fails on non-supported cases. I think this makes the Parsetree more self-documented (representing "_" as None would deserve some explanation) without really adding any kind of complexity. And one can imagine uses of other kinds of patterns by "extension expanders" (-ppx rewriters), such as list-comprehension stuff.

- Issue History
Date Modified Username Field Change
2013-11-26 05:38 ygrek New Issue
2013-11-26 06:48 gasche Note Added: 0010664
2013-11-26 14:44 frisch Note Added: 0010665
2013-11-26 15:00 gasche Note Added: 0010666
2013-11-30 22:56 doligez Note Added: 0010683
2013-11-30 22:56 doligez Status new => acknowledged
2013-12-02 19:04 frisch Note Added: 0010687
2013-12-05 09:35 frisch Status acknowledged => resolved
2013-12-05 09:35 frisch Fixed in Version => 4.02.0+dev
2013-12-05 09:35 frisch Resolution open => fixed
2013-12-05 09:35 frisch Assigned To => frisch


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker