8000 Simplify type bounds. by paulp · Pull Request #2405 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Simplify type bounds. #2405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Simplify type bounds. #2405

wants to merge 1 commit into from

Conversation

paulp
Copy link
Contributor
@paulp paulp commented Apr 17, 2013

I started out looking to limit the noise from empty type
bounds, i.e. the endless repetition of

class A[T >: _root_.scala.Nothing <: _root_.scala.Any]

This led me to be reminded of all the unnecessary and
in fact damaging overreaches which are performed during parsing.
Why should a type parameter for which no bounds are
specified be immediately encoded with this giant tree:

  TypeBounds(
    Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Nothing),
    Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Any)
  )

...which must then be manually recognized as empty type bounds?
Truly, this is madness.

  • It deftly eliminates the possibility of recognizing
    whether the user wrote "class A[T]" or "class A[T >: Nothing]"
    or "class A[T <: Any]" or specified both bounds. The fact
    that these work out the same internally does not imply the
    information should be exterminated even before parsing completes.
  • It burdens everyone who must recognize type bounds trees,
    such as this author
  • It is far less efficient than the obvious encoding
  • It offers literally no advantage whatsoever

Encode empty type bounds as

TypeBounds(EmptyTree, EmptyTree)

What could be simpler.

@paulp
Copy link
Contributor Author
paulp commented Apr 17, 2013

This will impact anyone who parses TypeBoundsTrees and never expects to see an EmptyTree in there. I don't know what can be done about that beyond alerting/preparing the usual parties.

I started out looking to limit the noise from empty type
bounds, i.e. the endless repetition of

  class A[T >: _root_.scala.Nothing <: _root_.scala.Any]

This led me to be reminded of all the unnecessary and
in fact damaging overreaches which are performed during parsing.
Why should a type parameter for which no bounds are
specified be immediately encoded with this giant tree:

  TypeBounds(
    Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Nothing),
    Select(Select(Ident(nme.ROOTPKG), tpnme.scala_), tpnme.Any)
  )

...which must then be manually recognized as empty type bounds?
Truly, this is madness.

 - It deftly eliminates the possibility of recognizing
   whether the user wrote "class A[T]" or "class A[T >: Nothing]"
   or "class A[T <: Any]" or specified both bounds. The fact
   that these work out the same internally does not imply the
   information should be exterminated even before parsing completes.
 - It burdens everyone who must recognize type bounds trees,
   such as this author
 - It is far less efficient than the obvious encoding
 - It offers literally no advantage whatsoever

Encode empty type bounds as

  TypeBounds(EmptyTree, EmptyTree)

What could be simpler.
@paulp
Copy link
Contributor Author
paulp commented Apr 17, 2013

I hope I can screw around with the position of this tree for the rest of my natural life.

@paulp
Copy link
Contributor Author
paulp commented Apr 17, 2013

Fuck. This.

@paulp paulp closed this Apr 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0