class Customer(var username: String)class Customer(username: String)class Customer(username: String) {
_username = username
private var _username: String = null
def username = _username
def changeUserName(requested: String) = {
// check for uniqueness and throw exception if not, otherwise set it
_username = requested
}
}class Customer(readonly var username: String) {
def changeUserName(requested: String) = {
// check for uniqueness and throw exception if not, otherwise set it
username = requested
}
}class A() {
@Column(name = "user_name")
readonly var username: String
def changeUserName(requested: String) = {
// check for uniqueness and throw exception if not, otherwise set it
username = requested
}
}--
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 scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Your response indicates you might have only read the subject line. Try reading the rest.
22 feb 2015 kl. 04:55 skrev kraythe <kra...@gmail.com>:
Would you like to point out how a macro can be made to allow hibernate mapping in an entity on my field?
And even if it is possible it does not diminish the point that it should be a language feature.
--
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 scala-user+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
But I do take particular issue with your assertion that you've been "arguing a technical point" only. You've introduced topics like ROI, the "meager penetration of Scala in the business world" and the supposed hostility of the community. These are not technical points, but you pointed them out anyway. Neither I nor anyone else in the Scala community would normally bother to raise a point like this, but it is really wearying to be trying to help and to be criticized for it.
Please, try to be constructive and considerate. Other people are trying to find an answer for you, but they are nonetheless human and I think there's a limit on the number of times we can propose macros as a possible solution without any indication that you'll consider it viable. I notice that Eugene hasn't replied to your question about macros yet, though I wouldn't be surprised if he didn't have time to write or find the code example for you; often he does, and he frequently goes beyond the call of duty to help.
One last thing: you're completely correct about breaking legacy code. We should be willing to do it where there's a clear benefit, so the question is usually "is it worth it"? I'm generally in favor of more breaking changes, but that's because I'm not a corporation.
Cheers,
Jon
On Sun Feb 22 2015 at 18:07:51 kraythe <kra...@gmail.com> wrote:
Abrupt? I haven't dismissed anyone nor have I implied that the world should adapt to me. Nor have I demanded the patience of anyone in educating my "poor misguided" self. I have been arguing a technical point and that is all. I don't care who the person is disagreeing I just care about the technical points, nothing less nothing more. If the way the community goes, to rip people for disagreeing, is this I might as well dump scala now as it will be the next Haskell, an interesting but useless language in anything but niche applications. Let's just look at the meager penetration of scala in the business world and pair that with its complexity and a hostile community and it's no wonder many great developers take a pass.
Back to the technical matter at hand, do you really assert that a public read only and private read write var is only useful to Hibernate? I can't believe you could think that. To me this equates to "just make all attributes public" or "encapsulation is a bad idea" or "object oriented engineering is silly". All of those I can't imagine would be put forth by such talented people. Scala fuses OO with functional programming, immutability with mutability, it's a brilliant cross between the ruby and Java worlds, trying to force it one direction seems to be counter to the principles of its invention.
As for breaking legacy code the history of scala is replete with such breakages and as I recall that is the reason that warnings that major versions of scala are incompatible. So I wouldn't ask for it to be retroactively changed but rather changed in next version. Or are we past that whole "this language won't be stuck in the legacy trap of Java mantra?" If the new mantra is "backward compatibility at all cost" then scala is doomed to suffer many of the problems Java does and with 1/100,000th of the market penetration.
--
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 scala-user+...@googlegroups.com.
On Fri, Feb 20, 2015 at 11:12 AM, kraythe <kra...@gmail.com> wrote:
This is incredibly verbose and very boilerplate. Instead we should be able to do something like thisclass Customer(readonly var username: String) {
def changeUserName(requested: String) = {
// check for uniqueness and throw exception if not, otherwise set it
username = requested
}
}
The closest would be this:
class Customer(private var _username: String) {
def username = _username
def username_=(requested: String): Unit = {
// check for uniqueness and throw exception if not, otherwise set it
_username = username
}
}
Or alternatively:
class Customer(private var _username: String) {
def username = _username
def changeUserName(requested: String): Unit = {
// check for uniqueness and throw exception if not, otherwise set it
_username = username
}
}
The first allows you to do customer.username = "New username", the other is customer.changeUserName("New username"), i.e. purely syntactic difference.