Jump to content

David Heffernan

Members
  • Content Count

    3710
  • Joined

  • Last visited

  • Days Won

    185

Posts posted by David Heffernan


  1. 55 minutes ago, Lars Fosdal said:

    I have not really thought about how the variable of a for in loop over an array of records is kept.
    Do we see a deep copy of the array element in the loop variable, or is there pointer magic involved?
    I can see how this could be a problem if the reference passed is to a local stack copy.

    Loop variables are assigned using assignment semantics. That's all you need to know. 


  2. It's the same issue for both types of for loops. The value of the loop variable is undefined if the for loop terminates normally. In your case that corresponds to the condition never having been met. 

     

    Unfortunately though, whilst you are aware that there is an issue here, you have not correctly understood what the issue is. 

     

    1 hour ago, Mike Torrettinni said:

    I never rely on i being the same value after loop as when 'condition' is met, so I assign i value to variable (vIndex)  so I can use the value of i  after the loop

    That reasoning is incorrect. The loop variable i does not change in case of a normal termination, e.g. the break in your code. 

     

    Before you consider for in loops I recommend that you correct your misunderstanding of for loops. 

     

    Executive summary. There is an issue with for loops of both kind. It is the same issue for both kind of for loop. But the issue is not what you have described. 

    • Thanks 1

  3. Why are you cross posting?

     

    https://stackoverflow.com/questions/64010603/delphi-getting-stream-read-error-on-really-simple-program

     

    At every site where you cross post, potentially different people will provide you the answer. Which means that more people than necessary spend time on this. As a broad rule, people who provide this sort of help don't appreciate this kind of behaviour.

    • Like 2

  4. 27 minutes ago, dummzeuch said:

    I'm encountering this problem regularly when some component isn't installed in the IDE or is installed but in a different (usually older) version. It would be nice to simply open that dfm as text and be able to make rudimentary changes to it. Most of the time it is enough to remove or change some properties from the dfm to make it load normally. The IDE always offers to delete a property or control, but I don't trust it (and I have reasons for that).

    Currently I open the dfm in a text editor but that's rather inconvenient.

    OK, this is making more sense to me, and I can better appreciate the inconvenience.

    • Like 1

  5. 26 minutes ago, Memnarch said:

    You are massively underestimating this 😛

    Maybe. I guess I might not be encountering the problem regularly. You must be facing it very regularly I guess. 

     

    28 minutes ago, Memnarch said:

    If you refactor a base component other visual components dervive from, loading/opening projects might fail. I support the Idea that the ide still loads the dfm as text. Right now it does not allow me to look at it, which is cumbersome. Just like WPF in VS where I always get the XAML editor but not a visual editor when the XAML is invalid.

    Isn't that a different issue? 


  6. 18 minutes ago, Tommi Prami said:

    And find file from disk and the spot, sure diff to repo will help, but still, would be life saver when this happens. 

    You are massively overstating this. Finding a file from disk is not difficult. Yes it takes a few seconds, but then it's not like this issue happens regularly. Every feature takes resources to implement. Given the immense problems that the entire Delphi product has, I for one would be disappointed if Emba spent resources on features like this that bring so little benefit.


  7. 6 minutes ago, Tommi Prami said:

    Would be nice IDE would always convert binary to text, if there are one. Got hit by that this summer, there still was few binay dfm's in our repository.

    Not sure the IDE should do that. There are tools to convert. If you want to convert, then use those tools. If the IDE did this automatically then that would be painful for people who wanted to use binary.

    • Like 1

  8. 1 hour ago, Fr0sT.Brutal said:

    Ah yes right I haven't noticed the getter returning pointer to array item. In my record list class I use dynamically allocated records and store pointers only so have no such issues.

    Well, you avoid some of the issues, but not all. For instance you don't avoid the issue where an item is deleted, but a stale pointer is retained. Additionally you end up with a large number of heap allocations, and memory that can be scattered which can impact performance.


  9. 1 hour ago, Uwe Raabe said:

    If I got that right, Stefan is referring to the case where the array is relocated, which invalidates the record pointers. This is not the case for a class list, where only pointers to the class instances are stored inside the array. Relocating such an array will keep the instance pointers intact.

    Granted the indirection that is offered by a reference type does make some of the issues hard to trip over, but they still exist.

×