Results 1 to 10 of 30

Thread: Yet another segfault (a.k.a. Darkhog is a total noob)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Oh fair enough I was going off some page I googled in terms of Assigned which showed three definitions, just checked in FPC and yes it's built in.

    http://stackoverflow.com/questions/4...ssigned-vs-nil

    May as well use assigned. doesn't make a blind bit of difference really. If you're dealing with method pointers to methods that return pointers/objects then using assigned will help you avoid making mistakes I suppose but if you were doing that and used pointers / nil comparisons a lot then you wouldn't make that mistake anyway. Well you'd hope
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  2. #2
    Well, here's the point. For some implementations, Assigned() may not be just a simple Nil check. For example, let's say that the Foo implementation of FPC does a Nil check AND a check for "0xbaadf00d" (uninitialized data value) to determine if a pointer is valid. If you port your code to Foo, which just checks Nil with a conditional, it may cause an unintended side effect.

    Practically, they are identical, but methodologically, they aren't. It goes back to the same reasons why it is bad to do pointer arithmetic, as in C-like languages... pointers need to be treated as opaque types, and depending on them being specific constant values is just generally a bad practice overall (and why Object Pascal is a much superior language than, say C++).

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
  •