no, but you did in your second one and I replied after it
no, but you did in your second one and I replied after it
I code in C as one of my jobs. I praise, and would at any time choose, the pascal way of declaring variables. Having a section for itself for variables is just so much better for clarity and coding efficiency. Especially experienced c coders utilize extremely ugly and confusing variable declaration practices.Originally Posted by marmin
That's where I like the way pascal requires a certain way of variable decleration for everyone. I see no advantage of your proposal
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
You have to tell the compiler what variables of which type you will use to allow the compiler to perform type checking and find 90% of stupid errors ("undeclared identifier", "type mismatch" etc) at the compilation stage.Originally Posted by marmin
If you are a computer and never make errors this is not for you.
In C++ you still have to declare all variables.Originally Posted by marmin
In Object Pascal you can use metaclasses to decide instance of which class to create at runtime.
And C++ can not do like this.
To answer the original post, how often do you make typos in variable names? If you answer "never", you are fooling yourself. Many script languages use the "create a variable first time it is used" method that you want, but the main problem with that is if you make a typo in a variable name, it creates a new and different variable than the one you intended. Then you spend the next hour or more wondering just WTF is going on with your code.
I use C++ in my usual job, and I adore how variables can be declared just prior to use. It annoys me in Pascal to have to move up to the top of the function just to declare a variable, then move down again to where I want to use it. Also, being able to re-use the same variable name for several different things is great for reducing the number of esoteric variable names that get created just to differentiate one variable from another.Originally Posted by JSoftware
This is a very simplistic example, but it shows how we use variable declarations.
Code:for (int i = 0; i < 4; ++i) { NodeType1 *pNode; // Do something with i and pNode } for (int j = 0; j < 4; ++j) { NodeType2 *pNode; // Do something with j and pNode }
I think this is becomming a flame war
I use C for microprocessors, which might explain something. Here you have to think about any variable you declare as the ressources I have are extremely sparse. Having the variables declared in a section for itself would be way better for me.
I can ofcourse do that but others can choose not to do that and use inline decleration of variables. Then the day I need to weed out in the loads of variables declared, resize too big arrays, etc. I'll have to sit and look through every line in each procedure to look for some very camoflaged variables
That's such a PITA
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Marmin, if you don't want to declare a variable you don't have to, you could always use the with keyword .
[pascal]
with TMyClass.Create do
begin
// call all the class methods here.
end;
[/pascal]
Of course there is nothing stopping you from creating your own branch of Object Pascal that implement the features you describe.
Computer languages are very Darwinian in nature. Those that people find useful survive, and those that are not seen as useful will not survive. So my suggestion is to create your own compiler and let it loose on the community. If developers use it and find that it meets their needs, it will survive.
Then how come Visual Basic (and other branches of basic language) still exist? They must have met a dead end of evolution decades ago.Computer languages are very Darwinian in nature. Those that people find useful survive, and those that are not seen as useful will not survive.
Whether we like it or not VB fitted a lot of developer needs in it's day. I actually believe that without the proliferation of VB in the Win 3.1 and early Win32 days, the Windows market would not have grown as quickly as it did. It allowed the creation of lots of new software rapidly. More software sold more Operating systems etc. So it had it's place. But VB is no longer as popular as it was and I think is reaching it's evolutionary end.Originally Posted by Dan
Bookmarks