Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 44
  1. #16
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    I think you're missing the point. It is to do with coding style/guidelines, if you have a project with multiple people working on it, having them each code under their own coding style will end up with the code being very messy.

    A project needs to set coding guidelines/standards/whatever-you-want-to-call-it and then stick to them.

  2. #17
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Error 404
    I think you're missing the point. It is to do with coding style/guidelines, if you have a project with multiple people working on it, having them each code under their own coding style will end up with the code being very messy.

    A project needs to set coding guidelines/standards/whatever-you-want-to-call-it and then stick to them.
    Err, I see, then yes, that is what I was trying to show. I never called it that, we just figured out how to code it and stick with that syntax, so yes, it is styling/guidelines.

  3. #18
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by Element
    Err, I see, then yes, that is what I was trying to show. I never called it that, we just figured out how to code it and stick with that syntax, so yes, it is styling/guidelines.
    All 3 of these follow the same syntax, but not the same styling/guidelines.
    PHP Code:
    <?php

    // Example 1
    if ($num == 0) { echo 'Bob'; }

    // Example 2
    if ($num == 0) {
    echo 
    'Bob';
    }

    // Example 3
    if ($num == 0)
    {
        echo 
    'Bob';
    }

    ?>

  4. #19
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Guidelines are there for a reason, but may be different depending on a project. One coding guideline is often "dont duplicate built in functions unneccesarily", which is how this whole discussion started out.

  5. #20
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Error 404
    All 3 of these follow the same syntax, but not the same styling/guidelines.
    PHP Code:
    <?php

    // Example 1
    if ($num == 0) { echo 'Bob'; }

    // Example 2
    if ($num == 0) {
    echo 
    'Bob';
    }

    // Example 3
    if ($num == 0)
    {
        echo 
    'Bob';
    }

    ?>
    Yeah. I don't know why you guys call it styles or guidelines, its just as easily, and more simply, the format of the syntax.

  6. #21
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Element
    Yeah. I don't know why you guys call it styles or guidelines, its just as easily, and more simply, the format of the syntax.
    No... its not.

    Syntax is the rigid way in which a language must be typed. This is the same for spoken languages as well as computer languages, its a set of instructions. For example, a capital letter must follow a full stop.

    The style or guideline is the additional way we represent the code to promote readability. For example, in some exam papers teachers ask for double line spacing, not becuase the english language syntax calls for it, but becuase it makes it easier for them to write their comments.

  7. #22
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by missing-score
    No... its not.

    Syntax is the rigid way in which a language must be typed. This is the same for spoken languages as well as computer languages, its a set of instructions. For example, a capital letter must follow a full stop.

    The style or guideline is the additional way we represent the code to promote readability. For example, in some exam papers teachers ask for double line spacing, not becuase the english language syntax calls for it, but becuase it makes it easier for them to write their comments.
    Yeah thats exaclty what the format of syntax is. Syntax being the code and the format of the code is how it is represented.

  8. #23
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Grrr, this is starting to get on my nerves a bit now...

    Format is a word usually used to describe a specific set of instructions... A PNG file is in PNG file format. If it wasnt in this format, it wouldn't be a PNG. The PHP function number_format formats a number to a specific format set. It is not given a guideline when formatting the number, its given a strict format.

    An additional tab and indent in a PHP script is nothing to do with the file format, and IMO, should not be described as file formatting. When its interpreted, the PHP library doesn't care about spaces, tabs, indents etc unless they are meaningful (eg: in a string).

    The guideline of coding would be a reccomended use, to promote readability. Say for example, you state that all declared functions should be camel-case (eg: readFileData()) and all opening braces should be proceeded by a newline and indent.. A model piece of code:

    PHP Code:
    function readFileData(){
       
    // Do something...

    So.. We have a perfectly sensible guideline... What happens if we break the guideline though, and dont do a newline? Well.. nothing, we just dont have such easy readability, but no functionality is lost.

    However, if the file format called for a newline and indent after every brace, and we broke the format by not doing that, the file should technically be corrupt (as it doesn't follow the format) and therefore wouldn't work. But of course, it would, hence why tabbing and indenting and other things to promote readability have nothing to do with the syntax format...

  9. #24
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by missing-score
    Grrr, this is starting to get on my nerves a bit now...

    Format is a word usually used to describe a specific set of instructions... A PNG file is in PNG file format. If it wasnt in this format, it wouldn't be a PNG. The PHP function number_format formats a number to a specific format set. It is not given a guideline when formatting the number, its given a strict format.

    An additional tab and indent in a PHP script is nothing to do with the file format, and IMO, should not be described as file formatting. When its interpreted, the PHP library doesn't care about spaces, tabs, indents etc unless they are meaningful (eg: in a string).

    The guideline of coding would be a reccomended use, to promote readability. Say for example, you state that all declared functions should be camel-case (eg: readFileData()) and all opening braces should be proceeded by a newline and indent.. A model piece of code:

    PHP Code:
    function readFileData(){
       
    // Do something...

    So.. We have a perfectly sensible guideline... What happens if we break the guideline though, and dont do a newline? Well.. nothing, we just dont have such easy readability, but no functionality is lost.

    However, if the file format called for a newline and indent after every brace, and we broke the format by not doing that, the file should technically be corrupt (as it doesn't follow the format) and therefore wouldn't work. But of course, it would, hence why tabbing and indenting and other things to promote readability have nothing to do with the syntax format...
    Oh jesus, Missing-Score, get over yourself. The word Format has its own god damn meaning, and one of this is how things are formated and displayed. Like a list, how a list is formated, alphabeticle, etc. Just like in code, if I choose to format my code using spaces.

    Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.

  10. #25
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Quote Originally Posted by Element
    Oh jesus, Missing-Score, get over yourself. The word Format has its own god damn meaning, and one of this is how things are formated and displayed. Like a list, how a list is formated, alphabeticle, etc. Just like in code, if I choose to format my code using spaces.

    Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.
    Ugh, close this thread please

  11. #26
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Element
    Before you go geek on me think about what the word really means out side of coding as I am talking to you and not explaining code, I'm using words to describe things, to describe how I code, the format or layout of how my code is written.
    The point is, we are talking about the word in a coding context, sure, if we were talking about something else then fair enough, but its down right wrong to think of tabs as part of file formatting in a case when it doesn't matter.

    I dont see why I should "get over myself" when clearly you are in the wrong, and have been pretty much throughout the entire thread. I dont exactly enjoy having to try and make up for incorrect information posted, but I think its important that new users dont think that your posted function was the best way to get path information and that part of PHP's file formatting involves tabs and indents.

    Anyways, I agree with ralph l mayo and will most likley be closing this thread sometime soon as it doesn't seem to be going anywhere.

  12. #27
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by missing-score
    The point is, we are talking about the word in a coding context, sure, if we were talking about something else then fair enough, but its down right wrong to think of tabs as part of file formatting in a case when it doesn't matter.

    I dont see why I should "get over myself" when clearly you are in the wrong, and have been pretty much throughout the entire thread. I dont exactly enjoy having to try and make up for incorrect information posted, but I think its important that new users dont think that your posted function was the best way to get path information and that part of PHP's file formatting involves tabs and indents.

    Anyways, I agree with ralph l mayo and will most likley be closing this thread sometime soon as it doesn't seem to be going anywhere.
    How am I in the wrong? I am not in the wrong because I havn't done anything wrong. When you talk to someone you talk to them. Just because a computer language componant is named something, like a file format or type. But you need to know when thats what the words mean. If i'm obviously describing the style/guideline of a code I can use format as freely as I like because it is a word that describes it in the correct way.

    Just as Error 404 said "guidelines/standards/whatever-you-want-to-call-it"

    And there is no reason to close the thread because if you guys just now feel concerned with it even though its an old thread, and its apparently a useless method, why not just delete it? Apparently its not usefull and doesn't fall under the forum guidelines.

  13. #28
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Element
    How am I in the wrong? I am not in the wrong because I havn't done anything wrong. When you talk to someone you talk to them. Just because a computer language componant is named something, like a file format or type. But you need to know when thats what the words mean. If i'm obviously describing the style/guideline of a code I can use format as freely as I like because it is a word that describes it in the correct way.

    And there is no reason to close the thread because if you guys just now feel concerned with it even though its an old thread, and its apparently a useless method, why not just delete it? Apparently its not usefull and doesn't fall under the forum guidelines.
    Yes, you are free to use the word format, but the context matters. You make it sound like your readability formatting is part of the PHP file format, which it is not, and therefore, you are wrong if you were implying that. If you werent, then thats fair enough, you are not incorrect, but I want it to be completley clear, becuase its little things like this that can potentially hold people back.

    For example, up until 6 months ago, I didnt know you could do:

    PHP Code:
    $object->function()->somethingElse()->SomethingElse
    Becuase I was told once that it was not possible, I never questioned it. I only questioned it when I saw it in a script, and found out it was possible and I had been misguided. Since then, I have done my best to ensure that misguiding information is not given out becuase it can potentially hold back someones progression. If someone comes here and gets the impression that formatting for readability is neccesary and is part of a PHP file format then they have been misguided, which is what I am trying to prevent.

    I wouldn't delete the thread becuase i feel earlier on some useful points were discussed in terms of execution time and usage. While its true that your inital function is is a slower duplicate of a built in function, it is still useful, say for a beginner to see that the built in function is quicker and to learn about the built in function if they have never seen it before. I'm only continuing to argue my point becuase it would be nice if we could leave it open to any further discussion on the original post, however, it doesn't look like its going to happen.

  14. #29
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Disclaimer, I am not a licensed morphologist or grammarian, but, imho:

    Format and syntax both have special meanings in computer science. Format refers to schema for the arrangement of data, and syntax refers to a schema for the arrangment of logic. To say "format of the syntax" is kind of like saying "apple of the orange", although it's true most people will probably get your meaning.

    PHP Code:
    $var = array('one''two''three');
    $var[0] = 'one';
    $var[1] = 'two';
    $var[3] = 'three';
    // same format (data), different syntax (logic)

    $varone 'one';
    $vartwo 'two';
    $varthree 'three';
    $varone 1;
    $vartwo 2;
    $varthree 3;
    // same syntax (logic), different format (data)

    if (true) { echo $var; }
    if (
    true)
    {
        echo 
    $var;
    }
    // same syntax, same format, different style 

  15. #30
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts
    ugh... see thats why I hate typing out text. You always forget something and can never quite get clear without writing a couple paragraphs. Yes I know what you both mean, and I understand that, but what I mean has to do with the english language, which is why I used format as my descriptor.

    Anyways, I'm not going to continue to reply to this topic, it has so much junk people will think are valid posts with usefull information partaining to the topic title. Though there is other usefull information which could almost be revised for a Computer Language FAQ (About the code its self).


 
Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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