Bug 14077 – Letting compiler determine length for fixed-length arrays in return type

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-01-29T13:49:00Z
Last change time
2017-07-05T18:57:34Z
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-01-29T13:49:34Z
Possible case: int[$] returnSArr() { return [1, 2]; }
Comment #1 by monkeyworks12 — 2015-01-29T15:39:09Z
(In reply to Kenji Hara from comment #0) > Possible case: > > int[$] returnSArr() > { > return [1, 2]; > } Also consider the following: auto[$] returnSArr() { return [1, 2]; } const[$] returnSArr() { return [1, 2]; } //Etc. int[auto] returnAA() { return ["asdf":1]; } auto[auto] returnAA() { return ["asdf":1]; } immutable[auto[$]] returnAA() { return [[1, 2]:1]; }
Comment #2 by bearophile_hugs — 2015-01-29T15:45:38Z
(In reply to monkeyworks12 from comment #1) > (In reply to Kenji Hara from comment #0) > > Possible case: > > > > int[$] returnSArr() > > { > > return [1, 2]; > > } > > Also consider the following: > > auto[$] returnSArr() > { > return [1, 2]; > } > > const[$] returnSArr() > { > return [1, 2]; > } > > //Etc. > > > int[auto] returnAA() > { > return ["asdf":1]; > } > > auto[auto] returnAA() > { > return ["asdf":1]; > } > > immutable[auto[$]] returnAA() > { > return [[1, 2]:1]; > } What are the use cases for all this? Implementation efforts have a cost in time.
Comment #3 by monkeyworks12 — 2015-01-29T16:07:26Z
(In reply to bearophile_hugs from comment #2) > (In reply to monkeyworks12 from comment #1) > > (In reply to Kenji Hara from comment #0) > > > Possible case: > > > > > > int[$] returnSArr() > > > { > > > return [1, 2]; > > > } > > > > Also consider the following: > > > > auto[$] returnSArr() > > { > > return [1, 2]; > > } > > > > const[$] returnSArr() > > { > > return [1, 2]; > > } > > > > //Etc. > > > > > > int[auto] returnAA() > > { > > return ["asdf":1]; > > } > > > > auto[auto] returnAA() > > { > > return ["asdf":1]; > > } > > > > immutable[auto[$]] returnAA() > > { > > return [[1, 2]:1]; > > } > > What are the use cases for all this? Implementation efforts have a cost in > time. I just put them here for completeness in case any were overlooked. I'm not specifically requesting that they are implemented as well.
Comment #4 by dlang-bugzilla — 2017-07-05T18:57:34Z
I think this is something that would require a DIP today.