Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Andreas Berger
@Vincent thanks for your detailed reply :) @All Vinzent Hoefler wrote: On Wednesday 12 July 2006 11:34, Andreas Berger wrote: save and restore the floating point unit. I will need to do this for FPC, so if someone knows how to save and restore the FPU, I would apreciate the help. F(

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Felipe Monteiro de Carvalho <[EMAIL PROTECTED]>: On 7/12/06, Alexandre Leclerc <[EMAIL PROTECTED]> wrote: > In Delphi a class is always treated as a 'var' when passed in a > function since a class is a pointer to actual data; No, not really. It is always passed as a pointer, but here

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Michael Van Canneyt <[EMAIL PROTECTED]>: Ahem. Have you tried that ? Because it is manifestly NOT true: Ah! I learnd something today! You are completly correct: What IS true is that you can change the properties of S, even if it is passed by value or as const. But the pointer S ca

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Felipe Monteiro de Carvalho
On 7/12/06, Alexandre Leclerc <[EMAIL PROTECTED]> wrote: In Delphi a class is always treated as a 'var' when passed in a function since a class is a pointer to actual data; No, not really. It is always passed as a pointer, but here you want to change the pointer and not the contents of the clas

Re: [fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Michael Van Canneyt
On Wed, 12 Jul 2006, Alexandre Leclerc wrote: I tried the following: procedure ThisAndThat(bitmap: TBitmap); begin if not Assigned(bitmap) then bitmap := TBitmap.Create; end; function Test: boolean; var bitmap: TBitmap; begin bitmap := nil; ThisAndThat(bitmap); Result := Assigned(bitmap);

Re: [fpc-pascal] Variable visibility problem

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Michael Van Canneyt <[EMAIL PROTECTED]>: It's not good practice to have local variables with the same name as a public method/property. How will you tell which one is used ? (obviously you can find out, but at first glance it will not be clear) Well, I was always doing Self.SetName i

[fpc-pascal] Another Delphi mode question :) -- classes as parameter

2006-07-12 Thread Alexandre Leclerc
I tried the following: procedure ThisAndThat(bitmap: TBitmap); begin if not Assigned(bitmap) then bitmap := TBitmap.Create; end; function Test: boolean; var bitmap: TBitmap; begin bitmap := nil; ThisAndThat(bitmap); Result := Assigned(bitmap); bitmap.Free; end; In Delphi a class is alw

Re: [fpc-pascal] Variable visibility problem

2006-07-12 Thread Michael Van Canneyt
On Wed, 12 Jul 2006, Alexandre Leclerc wrote: 2006/7/12, Michael Van Canneyt <[EMAIL PROTECTED]>: This is not a bug. Your code will compile in DELPHI mode, but not in FPC mode. Ok, I do not want Delphi mode (I try never using this mode: I code in FPC isn't it?). But as a side question, is t

Re: [fpc-pascal] Variable visibility problem

2006-07-12 Thread Alexandre Leclerc
2006/7/12, Michael Van Canneyt <[EMAIL PROTECTED]>: This is not a bug. Your code will compile in DELPHI mode, but not in FPC mode. Ok, I do not want Delphi mode (I try never using this mode: I code in FPC isn't it?). But as a side question, is there a reason we can't do that in FPC? I should re

Re: [fpc-pascal] Variable visibility problem

2006-07-12 Thread Michael Van Canneyt
On Wed, 12 Jul 2006, Alexandre Leclerc wrote: Hi all, in Controls.pas there is TControl.SetName(). In a form I made a procedure with TMyForm.MyProcedure; var setName: string; begin //... end; The compiler complains about: frmMyForm.pas(467,3) Error: Duplicate identifier "SetName" It shou

[fpc-pascal] Variable visibility problem

2006-07-12 Thread Alexandre Leclerc
Hi all, in Controls.pas there is TControl.SetName(). In a form I made a procedure with TMyForm.MyProcedure; var setName: string; begin //... end; The compiler complains about: frmMyForm.pas(467,3) Error: Duplicate identifier "SetName" It should do no problems. But If I want to use SetName of

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Vinzent Hoefler
On Wednesday 12 July 2006 11:34, Andreas Berger wrote: > save and restore the floating point unit. I will need to do this for > FPC, so if someone knows how to save and restore the FPU, I would > apreciate the help. F(X)SAVE/F(X)RSTOR The X-Versions are more efficient, but only available on newe

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Jonas Maebe
On 12 jul 2006, at 13:00, Vinzent Hoefler wrote: "sched_yield()"? Seems to be POSIX, so I suppose it's available on most Unices. Indeed also exists on Mac OS X. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freep

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Andreas Berger
Since Dos can have multiple ways of multitasking (it could e.g. also plug in to DV or Win3.x or TopView via int 2FH etc) this model seems advisable to me. I assume you are implementing a basic fixed timeslicer? What are you going to use it for btw? This because DV/X (which is free nowadays) a

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Vinzent Hoefler
On Wednesday 12 July 2006 11:10, Marco van de Voort wrote: > > > > spinning loops on Mac OS X, so maybe sleep(0) is the same. > > > > > > Do you know a correct way of doing this on *nix? > > > > "sched_yield()"? Seems to be POSIX, so I suppose it's available on > > most Unices. > > Yes, and not so

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Marco van de Voort
> > > spinning loops on Mac OS X, so maybe sleep(0) is the same. > > > > Do you know a correct way of doing this on *nix? > > "sched_yield()"? Seems to be POSIX, so I suppose it's available on most > Unices. Yes, and not so recent ('93) that it is risky. At least FreeBSD seems to have it. _

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Vinzent Hoefler
On Wednesday 12 July 2006 10:57, Tomas Hajny wrote: > I certainly don't know a general solution for *nix. However, even old > "single-task" DOS provides such a function and it's a great help that > can be provided by programmer to scheduler in the underlying OS, so > *nix systems should provide su

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Vinzent Hoefler
On Wednesday 12 July 2006 09:58, Marco van de Voort wrote: > > On 12 jul 2006, at 11:25, Marco van de Voort wrote: > > > > sleep(0) is quite bad, because it may not necessarily give up any > > timeslice. At least very short nanosleeps seem to be implemented as > > spinning loops on Mac OS X, so may

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Tomas Hajny
Marco van de Voort wrote: >> On 12 jul 2006, at 11:25, Marco van de Voort wrote: >> >> > I doubt it. Note that it also probably needs enhancing of the >> > threadinterface with a giveuptimeslice functionality, something for >> > which >> > now sleep(0) is abused. >> >> sleep(0) is quite bad, becaus

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Marco van de Voort
> On 12 jul 2006, at 11:25, Marco van de Voort wrote: > > > I doubt it. Note that it also probably needs enhancing of the > > threadinterface with a giveuptimeslice functionality, something for > > which > > now sleep(0) is abused. > > sleep(0) is quite bad, because it may not necessarily give

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Vinzent Hoefler
On Wednesday 12 July 2006 09:15, Tomas Hajny wrote: > Well, multitasking <> multithreading. I'm not sure if DV or Win 3.x > provide special multithreading support for DOS applications... Nope, not really (at least for Win3.x). There are some services to aid multi-tasking-aware applications at th

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Tomas Hajny
Marco van de Voort wrote: >> Marco van de Voort wrote: . . >> However, it certainly depends on whether a general solution (not >> requiring special support like DV, etc.) is really feasible and >> practical. > > I doubt it. Note that it also probably needs enhancing of the > threadinterface with

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Jonas Maebe
On 12 jul 2006, at 11:25, Marco van de Voort wrote: I doubt it. Note that it also probably needs enhancing of the threadinterface with a giveuptimeslice functionality, something for which now sleep(0) is abused. sleep(0) is quite bad, because it may not necessarily give up any timeslice.

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Marco van de Voort
> Marco van de Voort wrote: > > me. > > I assume you are implementing a basic fixed timeslicer? What are you > > going > > to use it for btw? This because DV/X (which is free nowadays) afaik gives > > you preemptive scheduling on Dos. > > Well, multitasking <> multithreading. I'm not sure if DV

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Tomas Hajny
Marco van de Voort wrote: >> >> I need to implement some simple threading in a DOS application I am >> >> writing with FPC. What I need to know is the following: >> >> >> >> 1) Does FPC protect it's stack or can I allocate memory from the heap >> >> and point SS and ESP to it for the threads stack.

Re: [fpc-pascal] Threading in FPC DOS

2006-07-12 Thread Marco van de Voort
> >> I need to implement some simple threading in a DOS application I am > >> writing with FPC. What I need to know is the following: > >> > >> 1) Does FPC protect it's stack or can I allocate memory from the heap > >> and point SS and ESP to it for the threads stack. > >> > > > > I believe