Jump to content

David Heffernan

Members
  • Content Count

    3478
  • Joined

  • Last visited

  • Days Won

    171

Posts posted by David Heffernan


  1. 4 minutes ago, Dalija Prasnikar said:

    I hate to be the one saying this... but ARC compiler was a step in that direction. You cannot have memory safety without automatic memory management.

    I guess ARC per-se wasn't the big problem, it was more the attempt to support ARC compilers and non-ARC compilers with the same codebases??


  2. 17 hours ago, gioma said:

    The first character of the data tells me what type of data I have to work with.

    For this reason I have to separate the header from the rest of the message.

    This sounds completely broken. What if the file starts with the sentinel value that indicates that you have a utf8 payload.

     

    Why aren't you passing a separate header, and then the payload? And why are you passing utf16 at all. Isn't that just expensive. And if you must pass around utf16 please tell me that you are handling byte order correctly.

    • Like 2

  3. 5 minutes ago, Kas Ob. said:

    Delphi is way more safer than C and C++

    No it's not.

     

    5 minutes ago, Kas Ob. said:

    It is safer then C and C++ and you need to pay more for the extra work to make it comparable to Rust.

    But for real most the switching to Rust is due the security not the memory safety per se.

    Not really the point if a government agency will only accept work using tools that meet certain criterion. You can either follow the specification and have a chance of getting the work. Or argue about  the specification and be completely ignored. That's just reality.

    • Like 3

  4. 12 minutes ago, Vandrovnik said:

    Even native code may run slow, when compiler does not use registers efficiently, uses superfluous jumps etc.

    Not according to Embarcadero. According to Embarcadero Delphi is blazing fast because it uses native code.

     

    We all know that to be absolute marketing BS and in fact Delphi compilers produce shitty code that often runs very slowly. 

     

    Yes, my original post was sarcasm.

    • Haha 2

  5. 1 minute ago, Brandon Staggs said:

    Beg to differ. At the point you declare an instance of TRecA inside of TRecB, the compiler does not yet know how much memory a TrecA instance takes. 

     

    
    type
      TRecA = record;
      TRecB = record
        FieldA: TRecA;
      end;
      TRecA = record
        FieldB: TRecB;
      end;
    

    That's not my example. Nobody wants to do this with a value type because it's a non terminating recursion. Have a look at my example code to see what I'm actually talking about. 


  6. 1 hour ago, PeterBelow said:

    Because classes are reference type and records are value types. A variable/field of a reference type will always have a a known size, sizeof(pointer). A value type does have the size defined by the type and that would be unknown at the point of the foreward declaration. A one-pass compiler cannot handle that.

    None of that applies to my example above. 


  7. 3 minutes ago, dummzeuch said:

    As I originally said: It depends on the use case.

     

    My programs usually have only the main thread for the UI and possibly one or (very rarely more) worker threads that are independent of each other (no threadpool). In that case it does not matter whether the other threads continue to run or not.

    An exception won't work because I only use this method when I don't want to run the executable inside the debugger in the first place, so there won't be a dubugger to catch that exception.

    I don't really follow this. If you have to modify your code to add the message dialog, before you start debugging, then I'm not quite sure why you can't run with a debugger attached. If you are happy to attach the debugger later, why can't you attach it at the start?


  8. 3 hours ago, Cristian Peța said:

    It's not a compiler problem, but record variables are not class variables and when you declare a record variable it is allocated automatically.

    You enter into a infinite loop of circular allocation.

    
    type
      TRecA = record;
      TRecB = record
        FieldA: TRecA;
      end;
      TRecA = record
        FieldB: TRecB;
      end;
      
    var
      a: TRecA; //infinite circular allocation of memory

     

    This isn't really a great example. The sort of thing that I want to do with records, but cannot, is this:

    type
      A = record;
      B = record;
      
      A = record
        function foo: B;
      end;
      
      B = record
        function bar: A;
      end;

    I can get round this using helpers right now, but I don't understand why I can't do this directly as above.

    • Thanks 2

  9. 2 hours ago, dummzeuch said:

    As for David Heffernan's  comment: I'm talking about debugging, not production code. I thought that was clear from the context.

    If you are debugging then throwing an exception is the way to do it. Then the debugger freezes all threads. You surely don't want the other threads to continue running at this point.

    • Like 1
×