Skip to content

Code clarity: Make syntax for sequence expressions as simple as syntax for lists #74

@baronfel

Description

@baronfel

Submitted by Alexei Odeychuk on 3/11/2016 12:00:00 AM
4 votes on UserVoice prior to migration

I suggest simplifying syntax for generating sequences. It would be great to make it as simple as syntax for lists in F#.
For example,

let lst = [ 1; 2; 3; 4 ] // allowed
let sq = seq { 1; 2; 3; 4 } // not allowed, why?
// error FS0739: Invalid object, sequence or record expression.

Now, the F# syntax rules allow declaring a simple sequence expression as follows:

let se = seq { yield 1; yield 2; yield 3 }

I think syntax rules may well be simplified in that case. It would be more comfortable for language users to declare sequences with no need to write the yield keyword each time when they specify a new value for the sequence expression.
P.S. At the same time, there is no need to make any improvements in syntax for generating sequences using ranges specified in the form like 1 .. 10.

let lst = [ 1 .. 10 ] // allowed
let sq = seq { 1 .. 10 } // allowed, and that's good!

Original UserVoice Submission
Archived Uservoice Comments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions