Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Naming - Creating objects.

  1. #11

    Naming - Creating objects.

    no, but you did in your second one and I replied after it

  2. #12

    Naming - Creating objects.

    Quote Originally Posted by marmin
    If you fail to see the advantages of my proposal, I can't help 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.

    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

  3. #13

    Re: Naming - Creating objects.

    Quote Originally Posted by marmin
    Why do I have to tell the compiler what names I will use in advance. It strikes me as being a bit.. stupid. Why isn't compiler smart enough to recgnize a creation of an object and do the rest.
    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.
    If you are a computer and never make errors this is not for you.

    Quote Originally Posted by marmin
    Now, I am forced to use only new () and Dispose () (the old fashioned way), because I don't want the compiler to know what instances i'm going to use.
    >in c++ you can just do it . That's not my fault..
    In C++ you still have to declare all variables.
    In Object Pascal you can use metaclasses to decide instance of which class to create at runtime.
    And C++ can not do like this.

  4. #14

    Naming - Creating objects.

    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.

    Quote Originally Posted by JSoftware
    Quote Originally Posted by marmin
    If you fail to see the advantages of my proposal, I can't help 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.

    That's where I like the way pascal requires a certain way of variable decleration for everyone. I see no advantage of your proposal
    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.

    This is a very simplistic example, but it shows how we use variable declarations.
    Code:
    for &#40;int i = 0; i < 4; ++i&#41;
    &#123;
      NodeType1 *pNode;
      // Do something with i and pNode
    &#125;
    
    for &#40;int j = 0; j < 4; ++j&#41;
    &#123;
      NodeType2 *pNode;
      // Do something with j and pNode
    &#125;

  5. #15

    Naming - Creating objects.

    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

  6. #16

    Naming - Creating objects.

    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.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #17

    Naming - Creating objects.

    Computer languages are very Darwinian in nature. Those that people find useful survive, and those that are not seen as useful will not 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.

  8. #18

    Naming - Creating objects.

    Quote Originally Posted by Dan
    Then how come Visual Basic (and other branches of basic language) still exist? They must have met a dead end of evolution decades ago.
    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.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •