Board index » delphi » Re: Moving to C#

Re: Moving to C#


2005-11-30 03:26:56 PM
delphi34
Jesper Hogstrom [Borland] writes:
Quote
Don't worry, we are more than capable of handling that situation
should it occur. After all, we are four, he's only one :D
I didn't mean to give the impression I was looking out for your
welfare, Jesper. I do BDN work for John :-)
--
Cheers,
David Clegg
XXXX@XXXXX.COM
cc.borland.com/Author.aspx
QualityCentral. The best way to bug Borland about bugs.
qc.borland.com
"Son, when you participate in sporting events, it is not whether you win
or lose: it is how drunk you get." - Homer Simpson
 
 

Re: Moving to C#

Quote

The solution to the problem was a call to Panel.Dispose. IOW, leaving
the calling of IDisposable.Dispose for the Panel to the GC (as opposed
to explicitly calling it ourselves) was what caused the increasing
delay.

Hi David,
You created a control on demand and nether disposed it?
Well, there is this urban legand that GC will call Dispose. It won't do
that! What might happen is, that the class has a VB-monk safety mechanism
to call Dispose in the finalizer. Since GC runs in it is own Thread this
requires the finalizer to be synchronized. I don't have to mention that
this kind of thing can get pretty slow.
If something is an IDisposable, the first thing to do is running Reflector
and check if it really doesn't contain any unmanaged stuff. Only if you
can verify this you don't have to dispose it explicitly.
This is IMHO part of .Net 101 and most .Net languages have an using
statement to make this pretty nice to read/write.
(btw , using would be a great addition to native Delphi, too ;-) )
using (YourDialogPanel dialog = new YourDialogPanel(referenceToYourForm))
{
if (dialog.ShowDialog() == DialogResult.OK)
DoSomething...
}
Where you would use ShowDialog to fake the behaviour of a "real" dialog.
My point was, that this was no case of some esoteric strangeness in GC,
but a completely deterministic MemLeak or the reason why finalizers
usually suck. ;-)
btw: It was said that GC in .Net 3.0 can handle unmanaged stuff inside
managed processes as well. Let's see if this is going to happen or even
desirable. ;)
--- posted by geoForum on delphi.newswhat.com
 

Re: Moving to C#

Dave Nottage [TeamB] writes:
Quote
Ingvar Nilsen writes:


>if (x = y) then begin
>DoSomeThing(x);
>end;


Yaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!
No no no!! <g>
You and Wayne Niddery, I remember he also defends such a %&#?&& coding
style :)
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Moving to C#

Ingvar Nilsen writes:
Quote
Dave Nottage [TeamB] writes:

>LOL! I agree, however my first gripe would be that Else isn't
>aligned with If <g>

Oh <g>
But do you want to know my pet hate, over all the others?

if (x = y) then begin
DoSomeThing(x);
end;

Same with C style and Javascript

if (x == y) {
DoSomeThing(x);
}

Yes, I prefer:
if (x = y) then begin
DoSomeThing(x); end;
if (x == y) {
DoSomeThing(x); }
Both shorter, and more readable (all syntactic noise moved out to the
right).
--
Jan Nordén
Senior Software Architect
MDA products group
 

Re: Moving to C#

Iman L Crawford writes:
Quote
>if (x = y) then begin
>DoSomeThing(x); end;
>
>if (x == y) {
>DoSomeThing(x); }

<head explodes>IMO, that is the worst possible way to do it.
Yeah... totally gross.
--
Andy Syms
Technosoft Systems Ltd
www.technosoft.co.uk
ICQ 136991871
 

Re: Moving to C#

Iman L Crawford writes:
Quote
When I fired up the beta of d2006 and
played around with C# it looked strange with the braces lining up
like my begin/ends.
When I am compelled to write in C (being most of the time as I am
primarily an embedded programmer :-( ) I format it as close to Pascal
as I can.
--
Andy Syms
Technosoft Systems Ltd
www.technosoft.co.uk
ICQ 136991871
 

Re: Moving to C#

Jan Nordén [Borland] <XXXX@XXXXX.COM>wrote in news:438db333$1
@newsgroups.borland.com:
Quote
if (x = y) then begin
DoSomeThing(x); end;

if (x == y) {
DoSomeThing(x); }
<head explodes>IMO, that is the worst possible way to do it.
--
Iman
 

Re: Moving to C#

Ingvar Nilsen <XXXX@XXXXX.COM>wrote in news:438d4c03$1
@newsgroups.borland.com:
Quote
if (x = y) then begin
DoSomeThing(x);
end;
I don't like the above for pascal
Quote
Same with C style and Javascript

if (x == y) {
DoSomeThing(x);
}
I've finally accepted this as the norm in languages that use braces.
--
Iman
 

Re: Moving to C#

Jan Nordén [Borland] writes:
Quote
Yes, I prefer:

if (x = y) then begin
DoSomeThing(x); end;

if (x == y) {
DoSomeThing(x); }

Both shorter, and more readable (all syntactic noise moved out to the
right).
lol,
I really hope this is a joke :)
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Moving to C#

Iman L Crawford writes:
Quote
>if (x == y) {
>DoSomeThing(x);
>}


I've finally accepted this as the norm in languages that use braces.

Which and whose norm? Not in C# and Microsoft tools. VS.Net will
autoformat such a thing to
if (x == y)
{
DoSomeThing(x);
}
- luckily!
The line you save by having the begin/{ put on the first line will soon
lead to very difficult to read code when you have many lines and in them
nested conditions.
It is not for no reason MS has found out how it shall be.
What about:
procedure TForm1.Button1Click(Sender: TObject);begin
ShowMessage('hello');
end;
Looks stupid, right?
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Moving to C#

Ingvar Nilsen <XXXX@XXXXX.COM>wrote in news:438dc165$1
@newsgroups.borland.com:
Quote
Which and whose norm? Not in C# and Microsoft tools. VS.Net will
autoformat such a thing to
Java, Java Script, PHP, C/C++. When I fired up the beta of d2006 and
played around with C# it looked strange with the braces lining up like my
begin/ends. That being the norm in C# makes me a happy man. :)
--
Iman
 

Re: Moving to C#

It will only do that if you have formatting set up wrong in the Options
menu.
"Ingvar Nilsen" <XXXX@XXXXX.COM>writes
Quote
>
Which and whose norm? Not in C# and Microsoft tools. VS.Net will
autoformat such a thing to
if (x == y)
{
DoSomeThing(x);
}
- luckily!
 

Re: Moving to C#

Don Strenczewilk writes:
Quote
It will only do that if you have formatting set up wrong in the Options
menu.
Nothing can be wrong set up in the options menu, hence the name of the
menu :)
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Moving to C#

Ingvar Nilsen writes:
Quote
>
>>if (x = y) then begin
>>DoSomeThing(x);
>>end;

No no no!! <g>
You and Wayne Niddery, I remember he also defends such a %&#?&&
coding style :)
I used to always place begin like above - from prior to using Pascal. I
still don't mind it but I have long since switched to putting begin on the
next line aligned with the end.
The one that is rife in the VCL code that drives me absolutely batty is:
if condition then Foo else
begin
Bar;
end;
No offense to the Borland developer that writes this, but - - Ugghhhh! STOP
IT!
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"A man is likely to mind his own business when it is worth minding,
when it is not, he takes his mind off his own meaningless affairs by
minding other people's business." - Eric Hoffer
 

Re: Moving to C#

Conclusion?
Ask "how to use MS tech" in a Delphi newsgroup. I am doing this all this
year and is a tactic advantage!
--
Mutis: The open source indexing/search engine for Delphi
(Alpha stage: Developers Wanted!)
AnyNet: Convert ANY .NET assembly to (almost!) working Delphi code!
(Beta stage)
mutis.sourceforge.net/