• 0 Posts
  • 16 Comments
Joined 1 year ago
cake
Cake day: July 22nd, 2023

help-circle



  • fluckx@lemmy.worldtoProgrammer Humor@lemmy.mlgot him
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    2 months ago

    What I meant was:

    In the screenshot it said x = *(++p) and iirc that is not the same as saying x = *(p++) or x = *(p += 1)

    As in my example using ++p will return the new value after increment and p++ or p+=1 will return the value before the increment happens, and then increment the variable.

    Or at least that is how I remember it working based on other languages.

    I’m not sure what the * does, but I’m assuming it might be a pointer reference? I’ve never really learned how to code in c or c++ specifically. Though in other languages ( like PHP which is based on C ) there is a distinct difference between ++p and (p++ or p+= 1)

    The last two behave the same. Though it has been years since I did a lot of coding. Which is why I asked.

    I’ll install the latest PHP runtime tonight and give it a try xD



  • Lets get one thing straight.

    This is rarely ever the developer and more a business stakeholder forcing you to push the Friday deploy button.

    I’ve had somebody in the business escalating to my team lead, head of development and CIO because i flat out refused to deploy something on Friday at 16h.

    So no. This is not the developer making a hard choice. There should be somebody coercing or forcing him to push the deploy button.




  • Correct. The way I’m used to it ( and how I thought the world worked ) is that the IDE gives tab a fixed length or characters. If you set it to 4 it would be the equivalent of 4 spaces or 4 letters or whatever.

    If my tab is set to 4 it would take up the width of 4 characters. If I need two indentations I would press tab twice.

    If bob then checks out my code and calls me a maniac and sociopath for using indentation and swears by “2”, the code would just look more condensed. The alignment would still work out because that’s done through spaces.

    var user_name = "Bob"
    var user_age[tab]= "Bob"
    

    This would align the = for Bob, because it needs two characters to align and that’s what his tab width is. It wouldn’t align for me because my tab width is 4. So I would.pur two spaces instead of the . That way it is aligned for everybody regardless of their tab width settings.

    The way you explain it sounds like how tabs works in MS Word ( or other word processors ).

    I don’t think I could work like that. I’ve only ever used IDEs to code ( regardless of how primitive they were back when I started). Interesting take though :D


  • What I mean with tab = x spaces is only visually and not actually ( there will ( obviously) still be a tab character in my preference. Not sure if that was clear.

    Because alignment are fixed characters compared to indentation. For indentation the only question is how many characters the next indentation needs to be.

    For alignment it is not fixed. As an example of PHP code:

    function test(&obj) {
    $obj->doSomething()
    ....->doSomethingElse()
    }
    
    

    The dots would be spaces because in IDEs people generally use a font where every character is equally wide.

    If I would tab again instead of spaces it could work out if my tab length display is ( for one or more ) adds up to the width of the variable $obj. If somebody else has a tab width of 2 rather than somebody who has 3. It would only align for one of the two people.

    Does make sense? I typed it out after a gym session on my phone.

    Additionally. The whole problem is resolved by using spaces for both alignment and indentation. But in the cursor would still jump one space at a time rather than the whole tab ( although there are keyboard shortcuts for jumping words which would jump all of em.

    I don’t know. Call me old fashioned. I like what I like :/


  • fluckx@lemmy.worldtoProgrammer Humor@programming.devwait what
    link
    fedilink
    arrow-up
    58
    arrow-down
    3
    ·
    edit-2
    4 months ago

    Honestly I always preferred tabs for indentation and spaces for aligning. It doesn’t break anyone’s experience. And if somebody wants two spaces for a two-space-tab-width for indentation and other people prefer four. That will work just fine.

    I hate seeing 2 space indents. Unreadable AF ( to me ). At least this way I can easily work in the same codebase without somebody being annoyed ( except for the crying about the tabs )