fslang-suggestions icon indicating copy to clipboard operation
fslang-suggestions copied to clipboard

Don't require a space before SRTP type parameter

Open moonPtr opened this issue 7 years ago • 12 comments

image

This makes a space between the opening angle bracket and the type variable necessary, which is inconvenient at best, ugly at worst.

(Was told to move this here from https://github.com/Microsoft/visualfsharp/issues/4794)

moonPtr avatar May 02 '18 14:05 moonPtr

I thought I had this reported as bug somewhere but I can't find it back. I think the F# spec actually allows this syntax, but the parser sees <^ as operator. Also, I thought there was an issue on allowing the type parameters on multiple lines, but without the impossibly wide indenting (must be after <.)

I'd certainly welcome this if this syntax is going to be allowed.

Though I'm unsure whether this is a language suggestion per se, it may well be an actual bug in the parser ;).

abelbraaksma avatar May 03 '18 23:05 abelbraaksma

It's a miialbug or issue, would it be possible to get a decision on this?

realvictorprm avatar Aug 30 '18 17:08 realvictorprm

@dsyme, @cartermp, any thoughts on this? Should this be moved and reclassified as a bug instead of a lang suggestion?

abelbraaksma avatar Sep 11 '18 12:09 abelbraaksma

I see this primarily as a compiler bug, since we should be able to disambiguate between a type definition and an operator usage, but I'm not sure how feasible that is.

cartermp avatar Sep 11 '18 15:09 cartermp

I'm fine with someone fixing this. I regard it as a glitch in the language definition (but it's in there and thus by design) which could be improved.

dsyme avatar Sep 11 '18 22:09 dsyme

@dsyme if you still agree, could you tag this approved-in-principle? Maybe someone will pick it up and open a PR.

abelbraaksma avatar Nov 30 '18 14:11 abelbraaksma

RFC is written.

cartermp avatar Mar 24 '20 17:03 cartermp

For ease of browsing, it's here: https://github.com/fsharp/fslang-design/blob/master/RFCs/FS-1083-srtp-type-no-whitespace.md

abelbraaksma avatar Jul 05 '20 00:07 abelbraaksma

Also there is

Microsoft (R) F# Interactive version 11.4.2.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> {|T=typeof<int>|};;

  {|T=typeof<int>|};;
  ----------------^

stdin(39,17): error FS0010: Unexpected symbol '}' in expression

> [|typeof<int>|];;
val it : System.Type [] =
  [|System.Int32
      {Assembly = mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;
       AssemblyQualifiedName = "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";

(Output below omitted)

Happypig375 avatar Jun 25 '21 08:06 Happypig375

@vzarytovskii i think this will fixed by https://github.com/fsharp/fslang-suggestions/issues/1151

edgarfgp avatar Jul 24 '22 10:07 edgarfgp

I think this is covered in IWSAMs @dsyme

vzarytovskii avatar Aug 25 '22 20:08 vzarytovskii

@vzarytovskii there was actually an RFC for this: https://github.com/fsharp/fslang-design/blob/main/RFCs/FS-1083-srtp-type-no-whitespace.md.

Maybe we should update that with a link to the implementation, as being part of the awesome #1151 work. I didn't check if this also solves the issue by @Happypig375 above, which is related, but not the same.

PS: the RFC also mentions the >: issue as well, was that covered in #1151?

val c<'T>: int // Error, thinks `:` is part of an operator

// Workaround - add a space
val c<'T> : int

abelbraaksma avatar Aug 26 '22 11:08 abelbraaksma

@vzarytovskii I've prepared marking this completed: https://github.com/fsharp/fslang-design/pull/714.

abelbraaksma avatar Oct 22 '22 15:10 abelbraaksma