Results 1 to 10 of 10

Thread: Ternary operator, begin/end

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Me, I'm so stupid I always have to write extra readable code otherwise I can't go back to it even 5 minutes later.

    Ternary however, is like + or -

    For example compiler directives have alternative way, one letter 'acronyms', that is way less readable than ternary operator.
    Last edited by Thyandyr; 19-05-2017 at 12:50 PM.

  2. #2
    Don't call yourself stupid for writing readable code. Based on my opinion writing readable code is very smart. Why?
    1. Having easy readable code means you can jump in and start expanding it at any time without spending time to relearning of how that code works.
    2. Easy readable code would also give you better starting position to start working with someone else in a team since they will understand your code more easily.


    Also not being able to understand some less readable code also doesn't mean that you are stupid. it only means that you have still something to learn.

    The only time that you should call yourself stupid is when stop learning because you think you can't learn either because you know everything or because learning seems to hard to you. So keep learning.
    I myself am an educated market salesman and komercialist but I still leaned about programming on my own to the point that I would probably be able to teach others a thing or two.

  3. #3
    Yes wasn't too serious, forgot to add smileys , but I do have horrible memory. One significant aspect is that I do not code full time, it's a side aspect of my job, and often done in time-fragmented chunks.

  4. #4
    I'm a hobby programer myself. Maybe if all goes well I will become full-time programer in the future. But till then I still have to learn a bit.

  5. #5
    Those overloaded iff functions are not so unreadable at all.

    I think they are great (especially for string concatenation), especially since with later delphi and fpc you can inline them, and not suffer any (correct me) performance penalty for calling a function (stack allocations, etc..)
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #6
    It depends on what you do with the parameters. I mean, the next code:

    Code:
      TheVariable := IFF (Something, TheVariable + 15, TheVariable * 2);
    generates the same executable than:
    Code:
      Tmp1 := TheVariable + 15;
      Tmp2 := TheVariable * 2;
      TheVariable := IFF (Something, Tmp1, Tmp2);
    May be the compiler can optimize it but I doubt FPC or Delphi are so smart even with -O4. In that case C's "?:" would generate faster code.
    No signature provided yet.

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
  •