-
Content Count
3499 -
Joined
-
Last visited
-
Days Won
174
Posts posted by David Heffernan
-
-
I know I go on about this but it's really important, in my view, to stress that the testing framework doesn't discover the bugs. It's the developer that writes good tests that discover the bugs.
You need a testing framework to help manage the test code. But the strength of the test is always the quality of the test code rather than the framework. There are plenty of libraries that ostensibly have test suites but are full of bugs because the test suites are incomplete.
- 3
-
5 hours ago, dummzeuch said:Too many of my questions on SO have been closed for me to rely solely on SO any more.
What about the people who you are asking for help?
I would post on one site first, and if you don't get a good response, then post elsewhere, with link to the first place.
- 2
-
3 hours ago, Rudy Velthuis said:Off-topic, but actually, that is multi-posting.
Cross-posting is posting to several newgroups on the same server, with one single post (i.e. the single post has multiple targets and a reply in one group will usually appear in the other groups too, unless the reply was specifically set up not to do that).
There are no newsgroups here.
-
The curse of cross posting ......
-
1 hour ago, Rudy Velthuis said:Not much, as this is only one function. And it is more elegant than passing a pointer and type info.
I would then make this function call a private function with the pointer obtained from the parameter and the typeinfo obtained from T.
That way, there will hardly be any bloat. And if this function is not critical, you will never notice a difference.
That's exactly what I suggested if you read on to the second paragraph.
-
4 hours ago, johnnydp said:Sorry I mean that code:
https://stackoverflow.com/questions/22002120/how-to-get-path-of-current-active-application-window
Thanks. Yes mentioned URLs to stackoverflow contain the same problem asking, but there are many answers and comments I don't know which one is realiable.
Has anyone had something similar in Delphi which works ?
That SO topic is the same issue as yours. You might have to do a bit of research starting there.
What you need to do is find the child process that actually implements the app. Lots of code examples to do that.
-
7 hours ago, KeithLatham said:That's the name of the executing process. Asker wants to know about external processes.
- 2
-
3 hours ago, johnnydp said:Std func
Well, nobody really knows what that is.
But your question is how to find the name of a UWP app from a top level window handle. Which is a question asked here https://stackoverflow.com/q/32001621/505088
- 1
-
23 hours ago, Rudy Velthuis said:A construct I use quite often.
So I guess you are happy to rely on the left to right order ......
-
54 minutes ago, Mahdi Safsafi said:I believe that you didn't understand me clearly. My answer wasn't about whether is pointless or not ! my answer was about the coding style (and I gave an example about the Win32 api).
Suppose I made a library that have a record like this :
type TDummy = record // ... public function Create(): TDummy; procedure Free(); end; { TDummy } function TDummy.Create: TDummy; begin // FOR NOW ... do nothing here ! end; procedure TDummy.Free; begin // on this platform do nothing for now ! // feature platform do something. end;
Currently Create and Free do nothing on Win32(x86). Yep there is no need to use them. But I use them just for future compatibility.
Now after 1 year, I decided to port my library to let say WinRT or MIPS. Now my Free must do something here (really)!
Now, from your approach, you must track all variables and free them if you want your code to run successfully on WinRT, MIPS.
For me, because I used them on all configurations, I wan't going to track them !
Also, is there any guaranties that "FContextToken" won't change to something else on future ?
No point planning for a future you can't see. The real problem was the stupid design in adding Create and Free methods that serve no purpose and confusing so many people.
Best strategy is to use a singleton for the context.
-
48 minutes ago, Mahdi Safsafi said:You read my explanation. From now, you' ve no excuses to use it without freeing it 😉 I'm watching you.
You are quite wrong. No point freeing it. No point even creating it.
- 1
-
1 hour ago, John Kouraklis said:I would be great if this were possible...
It's not possible. How could it be?
-
2 hours ago, Uwe Raabe said:Make the function a static class function of a record:
type TMyPassHandler = record public class function Pass<T:record>(const Value: T): Boolean; static; end; class function TMyPassHandler.Pass<T>(const Value: T): Boolean; begin Result := False; { do whatever is needed } end;
Most of the time the compiler should be able to infer the proper type, so a call would look like:
TMyPassHandler.Pass(myRec);
If the goal is to use RTTI then it seems questionable to use compile time generics. Will result in generic bloat. May as well pass the address of the record and the type info.
Or if you want to ensure type safety have the generic method call a further helper method that is non-generic and receives the address of the record and the type info. That avoids the bloat and gives benefit of type safety.
-
2 hours ago, dummzeuch said:function pass(var aRec): boolean;
or
function pass(const aRec): boolean;
How will you use RTTI with this?
-
11 hours ago, Rudy Velthuis said:Ok, sometimes (yeah, right, funny) I am dense, but what is SCCE? Source Code Compilable Example?
It's a typo. Should be SSCCE: http://sscce.org/
-
1 hour ago, David Schwartz said:Rudy said: I think this order is guaranteed, but I would not really count on it.
There's a compiler switch that overrides this, so it's not really "guaranteed".
The point about the order was to be sure that the condition was evaluated. Consider the two settings for the switch:
1. Left to right, condition is first sub expression, therefore it is evaluated.
2. Complete eval, all sub expressions are evaluated, therefore it is evaluated.
QED
-
7 hours ago, Rudy Velthuis said:I think this order is guaranteed, but I would not really count on it.
You can count on it. http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Expressions_(Delphi)#Complete_Versus_Short-Circuit_Boolean_Evaluation
Very surprised you don't know this.
-
7 hours ago, Rudy Velthuis said:Does Python run on a stack machine? Anyway, if they can manage to have proper if conditions too (and they do) then I don't see why they have this alternative syntax.
I looked and saw that CPython emulates a virtual stack machine.
Nothing to do with implementation details. The Python syntax is simply the Python equivalent of the C conditional operator. You know, the operator that is missing from Delphi.
-
4 hours ago, Lars Fosdal said:There is one, but you "wasn't about to download some project from a file sharing site" (i.e. a zip file with source code from Google Drive)
It's an extra step for every one of your readers. In fact it's multiple steps. Down file. Unzip file. One goal of the writer is to make it easier for the reader to see and understand.
For instance, if I was on a mobile device how would I read files in a zip file?
- 3
-
4 hours ago, Rudy Velthuis said:Or even better:
Result := Condition;
That's certainly more concise but it has a completely different meaning. Think about it Rudy.
-
12 hours ago, Mike Torrettinni said:Yes, no matter what i tried, it didn't compile. Was hoping there is simple solution, missing from help. No luck.
Seems kind of a waste of time this entire discussion. The language is well documented and is quite concise. The are only a handful of conditional statements. The syntax for if is clear. You have to write the code in the language that is provided to you. Use an if statement. End of story.
- 1
-
3 hours ago, Mike Torrettinni said:Well, I can't see anything helpful for my case. I'm looking here: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Declarations_and_Statements_(Delphi)
So you know the answer
-
1 hour ago, Mike Torrettinni said:Is it possible to switch the condition to the end:
from this:
If (condition) Then Result := True;
into something like this:
Result := True if (condition);
Or similar variation, where result is shown first.
I know that Case works like that, but I need it to work on string values.
When visually looking at the statement, sometimes the Result value has a 'priority' over condition - my personal preference.
What does the documentation say?
-
2 hours ago, Lars Fosdal said:@David Heffernan If you added me to your Ignore list here on DP, I would be totally fine with that.
I'd still see all the replies. It's an interesting topic that you raised but it needs a clearer example to bring out the issue.
HELP: Using C++ .dll in Delphi
in VCL
Posted
You can tell it must be stdcall since that is the only convention supported by classic VB.