Do nothing without doing anything
-
No love for the pythonic
None
?
-
And no love for
Nothing
that VB folks using too.
-
You can even define a pointer type that has methods that don't deference a null pointer when called, unlike languages like C++
I know for a fact that in C++ you can implement a pointer type and customize its behavior such that it doesn't dereference null pointers. The problem is that you would just want to throw an exception, and the check for whether it's a null pointer is a lot of overhead for a case that isn't supposed to happen and almost never happens in practice.
-
-
The problem is that you would just want to throw an exception, and the check for whether it's a null pointer is a lot of overhead for a case that isn't supposed to happen and almost never happens in practice.
That's why you should have different types for null and an actual pointer. Again, in Ceylon:
String? foo = null; // String? = String|Null variable String bar = "test"; if (exists foo) { // foo is a String, no need to cast bar = foo; } else { // this won't compile (Null is not assignable to String) bar = foo; } // this won't compile either (String|Null is not assignable to String) bar = foo;
We've had this discussion before, didn't we?
-
http://i.imgur.com/67KqOQd.png
I tried to chose 2.348237 options, but it didn't work.
-
And no love for
Nothing
that VB folks using too.NOTHING IS NOT NULL
NOTHING IS NOT NULL
NOTHING IS NOT NULLNothing
is what C# callsdefault(T)
.In VB.NET you can write
Dim number As Int32 number = Nothing
VB.NET has no real null.
-
In Cool, Nothing is a type with no values. Null is a type with one value (null). Nothing extends every type, and Null extends every type except Int, Boolean, Unit, and Nothing.
-
-
Well, when I say VB without mentioning .NET, I'm saying VB6 etc. ... but whatever.
-
It may have been called VB.NET back in 2003, but from VS2005, it's just been Visual Basic.
-
@Mason Wheeler said:
nil
I always chuckle when I see this. Were they too cool to use null or something?
-
Where ever was it said that I had to carefully research anything before spouting (externally apparently) stupid opinions?
-
1970 - Niklaus Wirth creates Pascal, a procedural language. Critics immediately denounce Pascal because it uses "x := x + y" syntax nil instead of the more familiar C-like "x = x + y" NULL. This criticism happens in spite of the fact that C has not yet been invented.
My all-time-favorite programming language suggestion:
x := x + y
is assignment;x == x + y
is an equality test;x = x + y
is a syntax error.
-
x := x + y is assignment; x == x + y is an equality test; x = x + y is a syntax error
+1
Not sure if that'd be my all-time favorite, but I've always wondered why the Pascal syntax is not more widespread.
-
My all-time-favorite programming language suggestion: x := x + y is assignment; x == x + y is an equality test; x = x + y is a syntax error.
I chose this from the beginning when I started making a hobby language. It just seems logical.
-
My all-time-favorite programming language suggestion: x := x + y is assignment; x == x + y is an equality test; x = x + y is a syntax error.
Don't get me started on assignment syntax and semantics in Verilog. You don't want to know.
Edit: The heck with trying to hide it in a
<details>
block; it's not working, and I CBA to figure out why. Three tries, three strikes, and Discourse is out.You were warned...
There are two types of assignments in Verilog, procedural and continuous. Procedural assignments have two sub-types, blocking and non-blocking. Blocking procedural assignments and continuous assignments use the same operator, although continuous assignments are non-blocking. Non-blocking procedural assignments use a different operator. Verilog, like the hardware it describes, it massively multithreaded; this is relevant because assignments may occur when certain implicit threads run, and may in turn trigger other threads (or even their own thread to run again).
Procedural assignments occur in a block of procedural code that executes in a thread. In most cases, these threads run automatically as a result of a change in a variable, and are infinite loops (
always
blocks) that run whenever a relevant variable changes.Blocking procedural assignments. These do pretty much what you expect software assignments to do.
c = a & b; e = c | d;
a
andb
are evaluated and the result is assigned toc
.c
andd
are evaluated and the result is assigned toe
.Non-blocking procedural assignments:
c <= a & b; // Yes, that's an assignment, not a comparison. c <= a <= b; would assign c the logical result of the comparison of a and b. Confusing? e <= c | d;
a
andb
are evaluated, but the result is not assigned toc
; it's scheduled for assignment later. Thenc
andd
are evaluated, butc
hasn't been assigned yet, so the old value is used; the result is again scheduled for later assignment. After all the RHSs have been evaluated, scheduled assignments are done. This may trigger some threads to run and reevaluate their RHSs, resulting in further assignments.Continuous assignments exist in a module outside any procedural block. They may occur as part of a variable declaration, or as separate assignment to a previously declared variable using the
assign
keyword. Each assignment is a separate thread that runs any time a variable on it's RHS changes value. There can be only one assignment to any given variable.wire a, b, c, d; // wire is a fundamental data type in Verilog assign c = a & b; wire e = ~a | c | d;
This is a non-blocking assignment. Suppose
a
is changed in some other code. The assignment toa
triggers the first thread to execute.a & b
is evaluated and scheduled for assignment toc
. The assignment toa
also triggers the second thread to run, and the result of its RHS is scheduled for assignment toe
. Later the scheduled assignment toc
occurs, triggering the second assignment thread to run again, possibly resulting in another scheduled assignment toe
. (If you create a set of circular dependencies, you may create an oscillator, intentionally or otherwise.)
-
The heck with trying to hide it in a
<details>
block; it's not working, and I CBA to figure out why.It's been broken serverside for quite some time. Don't worry, we have more than 1.5 threads on it.
-
Yeah, ok, but how does assignment work in Cool?
-
I'm not hipster enough to know anything about Cool.
-
Developers leaving large piles of commented and dead code around should be shot 0xdead, they smell. I also shudder every-time I see "archived" in our supposedly source repository. people, just delete the crap, it is not like you lose your precious golden nugget, you can always go back in history and bring back the zombie.
-
I've always wondered why the Pascal syntax is not more widespread.
It has one more character to type. And it is assignment operator, most used operation. Pascal also has the verbose BEGIN and END that I am very happy never got popularized, or I had to quit my programming and go become a fisherman contemplating the facts of life while peeing in the ocean or something.
-
It has one more character to type. And it is assignment operator, most used operation.
And that one character prevents the common "world's last bug," a class of errors that's all too easy to make in C:if (alertLevel = RED) { LaunchNukes(); }
And all for the want of a
horseshoe nailcolon character.C. A. R. Hoare, who's forgotten more about programming languages than most of us will ever know, had this to say on the subject:
I was eventually persuaded of the need to design programming notations so as to maximize the number of errors which cannot be made, or if made, can be reliably detected at compile time. Perhaps this would make the text of programs longer. Never mind! Wouldn't you be delighted if your Fairy Godmother offered to wave her wand over your program to remove all its errors and only made the condition that you should write out and key in your whole program three times! The way to shorten programs is to use procedures, not to omit vital ... information.
-
And that one character prevents the common "world's last bug,"
Some people object to doing this for stylistic reasons (although the reason given has always sounded to me like "I'm not going to let the compiler bully me, by gum!") is to, whenever you're comparing something to a constant, arrange the constant first.
if (RED = alertlevel)
is a compiler error. IIRC Visual Studio, though, will give you a warning if you use = in an if.
-
Some people object to doing this for stylistic reasons (although the reason given has always sounded to me like "I'm not going to let the compiler bully me, by gum!") is to, whenever you're comparing something to a constant, arrange the constant first.
My objection to that style is, "ugly, Yoda conditionals are!"
-
IIRC Visual Studio, though, will give you a warning if you use = in an if.
Aye, that it will. And if you have 'Warnings as errors' on (and if you don't, ), it'll get flagged as an error.
-
IIRC Visual Studio, though, will give you a warning if you use = in an if.
One of the reasons why you should use an IDE to write code, not an editor.
-
To be fair, so would csc.exe I think.
-
One of the reasons why you should use an IDE to write code, not an editor.
they make these wonderful things called lint tools that are fantastic on picking up on stuff like that. i highly recommend you look into them.
-
I know. Still: Why use 10 different tools when an IDE can do everything those 10 tools do and give you more context? Humans suck at multitasking.
Anecdotal evidence: When someone leaves dead code or "typo bugs" in our code base, it's usually the Vim users.
-
Why use 10 different tools when an IDE can do everything those 10 tools do and give you more context?
Because having those 10 different tools all open at once still uses less than half of a single IDE's RAM usage. Thankfully I now own a new computer with more RAM...
-
I know. Still: Why use 10 different tools when an IDE can do everything those 10 tools do and give you more context?
Any decent linter will be runnable within the IDE
-
it's usually the Vim users.
no, it's the ViM users who have not bothered to properly configure ViM with the necessary automated tools, such as syntastic, and who have ignored your suite of automated tests
it is not the fault of ViM that they did that, it is the fault of the users that they deliberately did not give themselves access to the tools they needed to work correctly and effectively.
-
no, it's the ViM users who have not bothered to properly configure ViM with the necessary automated tools, such as syntastic
OK, fine. I still don't get why you'd go through the pain of configuring all that when you could just use an IDE.
who have ignored your suite of automated tests
Well, ignoring them is hard, since we have a CI server. But everyone will get an email that the build failed. Which is annoying, as is the dead code.
RAM usage
If RAM usage is a problem for you, you're probably using Eclipse. ;) There's your problem, right there.
-
I feel like a good, low-memory footprint IDE could easily be written for something like Node.js... but nobody would use it because "IDEs are Icky!" has become a cargo cult. People would rather context switch back and forth between the command line and an editor than have an editor that can do their command-line tools built in (an IDE).
-
@accalia said:
no, it's the ViM users who have not bothered to properly configure ViM with the necessary automated tools, such as syntastic
OK, fine. I still don't get why you'd go through the pain of configuring all that when you could just use an IDE.
Says someone who's never had to manually configure tools in an IDE.
Yes, sometimes you have to.
-
OK, fine. I still don't get why you'd go through the pain of configuring all that when you could just use an IDE.
.... because you're gong to be doing just as much tweaking and customization to the IDE as it takes you to set up ViM as a proper IDE.
actually given how easy it is to set up ViM and how hidden some of the options are in some IDEs you're probably going to be spending less total time setting up ViM as an ide then you are any other "premade" IDE
and when you are done you have an IDE that takes a hundreth of the resources any other IDE takes, and is 150% as capable as all of the other IDEs as well.
I can't understand why you would choose to use any other IDE to be honest.
-
Says someone who's never had to manually configure tools in an IDE.
Srsly? Most of the time it's ticking checkboxes and putting the binary path in a text field (sometimes you can even skip that).
-
I feel like a good, low-memory footprint IDE could easily be written for something like Node.js...
you mean like.... say.... ViM?
lets see.... omnisense is already a thing, syntastic too... and it shouldn't be too hard to hook the node debugger into it as well...
yeah. totes doable!
-
Where is Visual Studio's tickbox for "just use my CMakeLists.txt"? It's a nightmare to develop using the Visual Studio projects that CMake generates.
-
Ew. I prefer my IDEs with a "close" button thanks.
-
@RaceProUK said:
Says someone who's never had to manually configure tools in an IDE.
Srsly? Most of the time it's ticking checkboxes and putting the binary path in a text field (sometimes you can even skip that).
So what you're saying is you prefer to use an IDE instead of something like Vim because you have to do exactly the same things in an IDE as you do in Vim?
-
Where is Visual Studio's tickbox for "just use my CMakeLists.txt"?
It's called "install CLion" ;)
-
Ew. I prefer my IDEs with a "close" button thanks.
You can get GUI wrappers for Vim
-
Do you have to type some arcane syntax to quit them? ;)
No, seriously though, the mouse was invented for a reason. Code-switching between controlling the editor and typing is too much cognitive overload for me. I want to focus on the code, not the editor.
-
Ew. I prefer my IDEs with a "close" button thanks.
ESC:q!ENTER
which i'm sure you can hotkey to a single keystroke if you so desire.
-
Five whole things I have to memorize, just to quit!
-
Do you have to type some arcane syntax to quit them? ;)
...optionalNo, seriously though, the mouse was invented for a reason. Code-switching between controlling the editor and typing is too much cognitive overload for me. I want to focus on the code, not the editor.
I believe that's the whole reason GUI wrappers for Vim even exist ;)
-
gVim still expects you to use the command line for anything it doesn't deem common enough to get a shortcut in the toolbar. I figure, if you don't want to use Vi-style commands, don't run something built for Vi-lovers.
-
That's fair; GUI wrappers for Emacs have the same issue, and it's not like even Visual Studio puts everything on a menu or an icon