Moderators: phlip, Moderators General, Prelates
gmalivuk wrote:Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Elench wrote:Either ≠ or ¬= here.
Though now I'm not sure if ¬ is in ASCII...
EvanED wrote:Elench wrote:Either ≠ or ¬= here.
Though now I'm not sure if ¬ is in ASCII...
Um, neither ≠ nor ¬ is ASCII. (Though ¬ is in Latin-1.)
addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
Роберт wrote:~= would be a decent idea.
<> terrible
EvanED wrote:Роберт wrote:~= would be a decent idea.
<> terrible
You call ~= "decent" and <> "terrible"? Really?!
Without any context, ~= looks to me like an ASCII rendition of "approximately equals", which is pretty close to the opposite of what you want. In the programming language context, I can think of a few things it could be along that line. For instance, some weakly-typed languages (*cough* Perl/PHP *cough*) will consider 4 == "4" to be true, but provide a stricter operation (e.g. ===) for equality with the same type; you could turn that around and make a language with == meaning the stricter operation, and then ~= would be a decent choice for the former. Or another example: ML doesn't provide an == operation (it calls it =, but whatever) for floating point types; you have to subtract and compare against some epsilon manually. You could imagine an ~= operator that does this automatically for some global epsilon setting. (Not sure this is a good idea... but you could imagine it at least.)
addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
Роберт wrote: Also, if you propose <>, why not propose ><?
phlip wrote:Роберт wrote: Also, if you propose <>, why not propose ><?
Well, BASIC, whence the <> operator comes, does accept "><". And also "=<" and "=>" for less-than-or-equal and greater-than-or-equal. Or at least, QBASIC and the VB tree accept them.
addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
EvanED wrote:some weakly-typed languages (*cough* Perl/PHP *cough*) will consider 4 == "4" to be true, but provide a stricter operation (e.g. ===) for equality with the same type
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
Well, yeah, but it means you have to invent a new symbol to represent mathematical equality. Why not just use the perfectly good symbol we've got for equality (which is even called 'the equals sign') and use something else for variable assignment?sourmìlk wrote:Okay, but it's not supposed to mimic mathematical equality.
R has that. I think a few languages us := as well.sourmilk wrote:Although I wouldn't mind a <- operator or something.
sourmìlk wrote:Okay, but it's not supposed to mimic mathematical equality. Although I wouldn't mind a <- operator or something.
Derek wrote:I prefer = for assignment and == for comparison, as opposed to := for assignment and = for comparison, because I use assignment more often than comparison. Also == corresponds with the other standard boolean operators in being two characters (<=, >=, !=, &&, ||).
Yakk wrote:I prefer := for assignment and == for comparison.
EvanED wrote:Actually I'd also consider just using ≠ (and ≤ and ≥) and letting people set up their editors so that they could get that.
addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
Роберт wrote:EvanED wrote:Actually I'd also consider just using ≠ (and ≤ and ≥) and letting people set up their editors so that they could get that.
Non ASCII code just seems weird to me.
public class ಠ_ಠAttribute : Attribute
{
public ಠ_ಠAttribute()
{
Debugger.Log(1,"Code Review Time","This code is bad and you should feel bad");
}
}
[ಠ_ಠ]
public class SomeClass
{
}
EvanED wrote:Derek wrote:I prefer = for assignment and == for comparison, as opposed to := for assignment and = for comparison, because I use assignment more often than comparison. Also == corresponds with the other standard boolean operators in being two characters (<=, >=, !=, &&, ||).
cls is fewer characters than class. Should C++/Java/etc. have made that the keyword instead? i is shorter than int. Imagine how many fewer characters you could type if C chose that! := and = makes more sense than = and ==.
EvanED wrote:Derek wrote:I prefer = for assignment and == for comparison, as opposed to := for assignment and = for comparison, because I use assignment more often than comparison. Also == corresponds with the other standard boolean operators in being two characters (<=, >=, !=, &&, ||).
cls is fewer characters than class. Should C++/Java/etc. have made that the keyword instead? i is shorter than int. Imagine how many fewer characters you could type if C chose that! := and = makes more sense than = and ==.
And sure, == has the same number of characters as <=, but you're ignoring < and >.
troyp wrote:That counterargument doesn't really hold because in those cases the shorter forms would be less readable.
And "i" would be unavailable to be used as a variable, further hampering readability (since "i" is often a very natural name for a counter or index variable)
I like := and = marginally better to read, but = and == significantly better to type. Note that they're easier to type even if assignment and equality are equally common, since "==" is easier to type than ":=" (well, it is to me, although it could be that I'm less used to it).
Derek wrote:But you don't actually need to type "class" very often, so a lengthy name is fine.
int x <- 2;
if (x = 3) puts("WTF??");
if (x != 3) puts("OK");
if (x <- 3) puts("Why would anyone do this?");int x = 2;
if (x == 3) puts("WTF??");
if (x != 3) puts("OK");
if (x = 3) puts("Common programming mistake");EvanED wrote:So I'm not saying my analogy isn't a bit of hyperbole, but I do think you can say the same thing about := and = vs = and ==. I think you'd get used to using i (or I) for int -- it'd be something you'd have to learn. I mean, you already have to learn that you type int instead of integer; it's just a matter of degree how abbreviated it'd be. Just like you have to learn that = isn't really = in the sense you're used to. In some ways, I think the = concept may even be harder to learn, because you have to break some degree of preconception about what it means.
Edit: think back to when you were learning your first C-like language... how easy was it to type if (a = b)? I think my first multi-hour debugging session was finding one of those. (Incidentally, that was what caused me to become an absolute freak about warnings.) Sure, some of those bugs were just typos, probably including my big one, but I think a substantial contributor is thinking is "I want to test if a equals b, and = means equals; after all, that's what I've known since kindergarten or whatever".
Edit again: now that I think about it more, I think there are some parallels between = being assignment and calling kilo=2^10 instead of 10^3 etc. In both cases, comp sci people took a concept/notation/word that already had a well-defined meaning and applied it to a somewhat-related-but-actually-pretty-different concept in CS for the reason that it was convenient to. And in both cases, I pretty firmly think it was the wrong decision.
So go with I then, or something.
ycc1988 wrote:
- Code: Select all
int x <- 2;
if (x = 3) puts("WTF??");
if (x != 3) puts("OK");
if (x <- 3) puts("Why would anyone do this?");
The improbability of typing that last line will eliminate many programming bugs, I presume, as compared to the current C syntax:
- Code: Select all
int x = 2;
if (x == 3) puts("WTF??");
if (x != 3) puts("OK");
if (x = 3) puts("Common programming mistake");
if(x < -3) puts("unhandled error");
if(x <- 3) puts("WTF??");
if(x<-3) puts("uh-oh, which situation is this?")addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
troyp wrote:That's a somewhat persuasive argument, although I do think it's specific to C-like languages.
It depends on "assignment instead of equality" being a potentially trickier bug to find than vice versa (after all, a novice programmer is just as used to using = for assignment as for equality).
(It would help if the compiler would give a warning if you used a pure expression somewhere a statement was expected, like it's own line or the initialization statement of a for-loop. I'm sure there are static analysis tools that do so, but if the compiler did it on standard settings it would help novices with this sort of error.)
Also, I'm not convinced that "=" for assignment is a different meaning. Assignment is really just the same as "let x = 2" (where the "let" is sometimes omitted).
Urghh! It looks like an identity matrix or something. I'm starting to think you're not as attached to your single-letter variables as I am
EvanED wrote:My impression is that programming-style assignment where you change the value of an existing variable is seen as bad form.
Derek wrote:EvanED wrote:My impression is that programming-style assignment where you change the value of an existing variable is seen as bad form.
See pure-functional programming languages. In imperative languages it's actually quite common, although in most cases of simple arithmetic you can use one of the shortcut assignments.
> let a = 3
- a = 4
val a : int = 3
> let a = 3
- a <- 4
a <- 4
^^^^^^
stdin(8,1): error FS0027: This value is not mutable
> let mutable a = 3
- a = 4
val mutable a : int = 3
> let mutable a = 3
- a <- 4
val mutable a : int = 4
> let a = 3
- let b = a + 1
val a : int = 3
val b : int = 4
> let isEven x =
- if x % 2 = 0 then
- "yes"
- else
- "no"
- let test = isEven 12
val isEven : int -> string
val test : string = "yes"
let a <- 3let a = 3if (x <- 3)ycc1988 wrote:But I can see how it would be confusing to see <- develop 2 usages depending on whether an assignment or a comparison operator is expected.
addams wrote:Politics is hard. I can't do it.
It takes a nasty Jr. High School Girl in a man's body to keep up.
ycc1988 wrote:In response to Роберт, I guess sincemakes no sense...
- Code: Select all
if (x <- 3)
As mentioned, R has <- assignment. I fired it up to see how that works:Роберт wrote:
- Code: Select all
if(x < -3) puts("unhandled error");
if(x <- 3) puts("WTF??");
if(x<-3) puts("uh-oh, which situation is this?")
<- would be absolutely terrible for assignment.
> x <- 2
> if(x < -3) { print('This works as expected') }
# No output
> if(x <- 3) { print('Oh god why?') }
[1] "Oh god why?"
> if(x<-3) { print('You deserve this bug.') }
[1] "You deserve this bug."EvanED wrote:troyp wrote:That's a somewhat persuasive argument, although I do think it's specific to C-like languages.
I don't agree here. I think other languages minimize the impact of = and == through means such as preventing assignments in conditions, but in a bit hyperbolic fashion I'd say that all they're doing is hiding the bad decision -- treating the symptom rather than the disease. (Of course, you might want to prohibit assignment in conditions for other reasons than "it's easy to accidentally put it there", so it'd also be reasonable to fix both problems.)It depends on "assignment instead of equality" being a potentially trickier bug to find than vice versa (after all, a novice programmer is just as used to using = for assignment as for equality).
I disagree with this statement. I'll say more about this later, but personally I think that the only significant place where you'd have people committing the opposite bug is when they're coming from current languages that use = for assignment. (It's for this reason that I say I might go with Yakk's idea of := and == if I were to design a language, though I'm not sure. Like assignments in conditions, it would also be possible to mostly prevent the opposite bug through other syntactic restrictions, e.g. making a top-level expression a == b syntactically invalid. Unlike assignments in conditions, I would hyperbolically say that this decision is hiding the bad decisions made in other languages rather than this one.)
Second, statements like let x = x + 1 I suspect are very rare within formal maths. At least in my experience, you'd see either (1) a new variable, (2) no "assignment" used and just x+1 in the future, or (3) in an iterated context, a subscripted version of x a la let xi+1 = xi + 1. My impression is that programming-style assignment where you change the value of an existing variable is seen as bad form.
Urghh! It looks like an identity matrix or something. I'm starting to think you're not as attached to your single-letter variables as I am
Probably not.But even if I was, I'd never use I as a variable name -- it starts with upper-case.
Users browsing this forum: Slageammalymn, Tebychacy and 3 guests