Why is final trait prohibited?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Why is final trait prohibited?

scala solist
As the subject says. I need to do some projection and need trait that would never be instantiated. I thought that final would be proper way to mark it as empty realization.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why is final trait prohibited?

Rex Kerr-2
A final trait would be useful only as something that can't be instantiated, which is sufficiently peculiar of a requirement so that it's more likely that it's an error than intentional.

If you want the same behavior, mark the trait sealed and don't put anything that extends the trait and is instantiable in the same file.

  --Rex


On Fri, Jan 27, 2017 at 10:01 AM, scala solist <[hidden email]> wrote:
As the subject says. I need to do some projection and need trait that would never be instantiated. I thought that final would be proper way to mark it as empty realization.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Why is final trait prohibited?

Jasper-M
In reply to this post by scala solist
You can have a final abstract class. https://issues.scala-lang.org/browse/SI-9464

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Why is final trait prohibited?

Naftoli Gugenheim
In reply to this post by Rex Kerr-2
It would be very useful for phantom types. You can't have String with NonEmpty if NonEmpty is a class.


On Fri, Jan 27, 2017, 1:31 PM Rex Kerr <[hidden email]> wrote:
A final trait would be useful only as something that can't be instantiated, which is sufficiently peculiar of a requirement so that it's more likely that it's an error than intentional.

If you want the same behavior, mark the trait sealed and don't put anything that extends the trait and is instantiable in the same file.

  --Rex


On Fri, Jan 27, 2017 at 10:01 AM, scala solist <[hidden email]> wrote:
As the subject says. I need to do some projection and need trait that would never be instantiated. I thought that final would be proper way to mark it as empty realization.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.