Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Craig Peterson
On 5/22/2014 2:35 AM, Michael Schnell wrote:
> For complex asynchronous  events, I tested this:
> 
>  - Define a class (sibling of TObject) ) that holds some data and the
> procedure to be used in the asynchronous callback.
>  - To through the callback event, create an instance and fill the data
> structure

This is exactly the "data marshalling" I was talking about.  Our
application is heavily asynchronous and it isn't an exaggeration to say
that there are hundreds of different calls with different functions and
parameter lists.  Having to define a new object, or even just a new
method and record and fill in that data is a lot of code, and
consequently there are plenty of cases that would benefit from more
asynchronous behavior or parallism that don't do so.

-- 
Craig Peterson
Scooter Software

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Craig Peterson
On 5/21/2014 3:53 PM, Sven Barth wrote:
> While I consider bounties a valuable instrument for Open Source
> development I personally don't like them. Especially in the way you are
> mentioning it (no offence here!) it would put quite some pressure on me
> which I'm honestly not a fan of.

No offense taken.  I'm a bit uncomfortable with it myself because I
don't want to disrupt the existing release plans, and things like
generics and packages do seem like better uses for your time.
Unfortunately there aren't that many people we could hire short term who
understand the code and would be able to do it in a reasonable
timeframe.  Ideally I'd just like to give the money to Blaise to finish
the work, but he didn't respond to my email.

-- 
Craig Peterson
Scooter Software

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Maciej Izak
2014-05-22 11:18 GMT+02:00 Sven Barth :

> Yes. Though first step is compile time packages and runtime packages
> later...
>
Any timeline?

Regards,
hnb
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Drawing window out line

2014-05-22 Thread Tomas Hajny
On Thu, May 22, 2014 10:51, Mark Morgan Lloyd wrote:
 .
 .
> Going back to the earlier message:
>
>  > note : we can not use Video and CRT Unit both in single unit. i want
>  > to use CRT unit only.
>
> Perhaps somebody would like to confirm this, but my understanding is
> that Video and CRT can't be used in the same /program/, not just the
> same /unit/. Unless there's a very good reason, I'd have thought that
> using FreeVision would have been the best way to go, since this already
> knows about things like window outlines and stands a reasonable chance
> of having already sorted out e.g. codepage selection issues.
 .
 .

Two comments:

1) (In)compatibility of units Video and Crt is platform (implementation)
specific thing. They can be used together without any issues on platforms
providing sufficient access to the console (i.e. basically anything except
for *nix platforms which provide limited set of console features
accessible across the different operating systems and technical
implementations) _as_long_as_you_know_what_you_do_ (i.e. you should
understand that changing the video buffer without UpdateScreen intermixed
with Crt.Write calls will obviously not give a reasonable outcome and
results of Crt.Write may not be accessible for reading via VideoBuf^).
Among others, this includes Win32 as well as far as I know.

2) FreeVision has its limitations too - especially when talking about
stuff like Unicode (which may be handled better in unit Crt due to fewer
limitations/more limited set of features provided there). Unfortunately,
that's partly valid also for unit Video - it would need to be
extended/updated for multibyte encoding, because the current
implementation hard-codes that the TVideoCell = word. I have started
working on extending and updating unit Video to cover this and allow
building unit Crt functionality on top of unit Video (and Keyboard) in
rather generic manner very long time ago, but I have never finished it
because it required quite a lot of time (in order to make it working on
all supported platforms) which I didn't have. Some concepts in this area
are still not completely obvious, because we may not have generic
(platform-independent) functionality for e.g. finding out how many display
characters are necessary for a Unicode string which may not be normalized
yet (i.e. it may include standalone accents which need to be combined with
the main letter, etc.).

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Michael Schnell

On 05/22/2014 11:33 AM, Marco van de Voort wrote:

I do something similar, but pool these event records in generic pools,

Great !

Could we have this in the RTL ?

Is it viable to create "closure" as a syntax candy on top of this ?

-Michael

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Ping problems - OS/X

2014-05-22 Thread Marco van de Voort
In our previous episode, Mattias Gaertner said:
> > I did note that the example said that it was flawed, but, foolishly,
> > as it turned out, I thought it meant 'flawed' rather than 'doesn't
> > work at all'.
> 
> Do you mean this example:
> http://wiki.freepascal.org/Executing_External_Programs#An_improved_example_.28but_not_correct_yet.29
> 
> It works here.
> What is wrong?

Not using

http://wiki.freepascal.org/Executing_External_Programs#.28Process..29RunCommand


:-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Marco van de Voort
In our previous episode, Michael Schnell said:
>   - To through the callback event, create an instance and fill the data 
> structure in the instance and then use TThread.Queue to through the event:
> procedure TmyThread.Execute
> begin
> ...
> AsyncEvent := TAsyncEvent.create;
> AsyncEvent.DataX := .
> AsyncEvent.DataY := .
> Queue(AsyncEvent.DoIt);
> 
>   - now forget the variable AsyncEvent :-) .
> 
>   - some time later the main Thread calls DoIt
>here we go:
>procedure DoIt...
>begin
>  X := DataX;
>  Y := DataY;
>  ... do stuff ...
>  Free;
>end;

I do something similar, but pool these event records in generic pools, so at
the end of the generic doit (I call it execute) it puts itself back in the pool.
The generic pool is complemented by a generic factory class.

I originally only pooled allocations over 1 MB, but since generics pooling
become easier I pool more readily. (never benchmarked if that matters for
small allocs of course. Big chance that the tthreadlist lock in the pool is
worse than the allocation/free with modern threadaware heapmgrs, since those
probably lock only once to sync multiple deallocations)
 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Sven Barth
Am 22.05.2014 09:44 schrieb "ko paka" :
>
> Hello,
>
> just out of curiosity - by packages do you mean delphi style dynamic
packages - bpl ?

Yes. Though first step is compile time packages and runtime packages
later...

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Drawing window out line

2014-05-22 Thread Mark Morgan Lloyd

Tomas Hajny wrote:

On Thu, May 22, 2014 09:55, Mark Morgan Lloyd wrote:

mokashe.ram wrote:

 .
 .

it's probably safe to assume that your instructor is reading this
mailing list with interest, perhaps he'd like to fill in what operating
system etc. your code's supposed to run on since you've not told us >:-)


In the first thread (coming from "different person" ;-) ), there's been a
post via Nabble (before the poster subscribed to the mailing list) where
he stated that the target was Win32. This e-mail never appeared on this
list because it went to the moderation queue as part of the spam
protection efforts and it was apparently deleted by one of the moderators
by mistake (either me or Jonas).


That's one of the problems when people use gmail: hints such as their 
real timezone are removed. One person pretending to be two, or asking 
similar questions as different threads, can happen if they don't 
appreciate that the etiquette in a mailing list differs from that of 
IRC: in the latter case one sometimes needs to ask multiple times as the 
user population "churns".


Going back to the earlier message:

> note : we can not use Video and CRT Unit both in single unit. i want
> to use CRT unit only.

Perhaps somebody would like to confirm this, but my understanding is 
that Video and CRT can't be used in the same /program/, not just the 
same /unit/. Unless there's a very good reason, I'd have thought that 
using FreeVision would have been the best way to go, since this already 
knows about things like window outlines and stands a reasonable chance 
of having already sorted out e.g. codepage selection issues.


However since this isn't CIX I think we need to answer the question as 
posed- once it's in a sufficiently-concise form that we have a chance :-)


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Drawing window out line

2014-05-22 Thread Tomas Hajny
On Thu, May 22, 2014 09:55, Mark Morgan Lloyd wrote:
> mokashe.ram wrote:
 .
 .
> it's probably safe to assume that your instructor is reading this
> mailing list with interest, perhaps he'd like to fill in what operating
> system etc. your code's supposed to run on since you've not told us >:-)

In the first thread (coming from "different person" ;-) ), there's been a
post via Nabble (before the poster subscribed to the mailing list) where
he stated that the target was Win32. This e-mail never appeared on this
list because it went to the moderation queue as part of the spam
protection efforts and it was apparently deleted by one of the moderators
by mistake (either me or Jonas).

Since there was no other information included and it didn't change the
situation substantially, I decided not to ask the poster for resending his
e-mail at that time (I do it in other cases if I notice such a situation
happening - you know, there are sometimes quite many spam messages, so one
may easily miss a valid one among them).

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Drawing window out line

2014-05-22 Thread Tomas Hajny
On Thu, May 22, 2014 09:00, mokashe.ram wrote:


Hi,

> Could Any One help Me  to  writing Horizontal and vertical line to message
> window in Free Pascal as i MEM and MEMW function not supported in free
> pascal.
>
> note : we can not use Video and CRT Unit both in single unit. i want to
> use
> CRT unit only.
>
> below is the my sample code
>
> PROCEDURE draw_window_outline(top_left_x,
>   top_left_y,
>   width,
>   height,
>   style,
>   fore,
>   back  : BYTE);
>
> VAR
>x,y: BYTE;
>offset : INTEGER;
>
>
> BEGIN
>  IF (style<>255) AND (width>2) AND (height>2) THEN
>  BEGIN
>   offset:=(top_left_x-1)*2
>  +(top_left_y-1)*160;
>   MEM[$B800:offset]:=top_left_corner[style];
>   MEM[$B800:offset+1]:=back*16+fore;
>   FOR x:=1 TO (width-2) DO
>   BEGIN
>MEM[$B800:offset+x*2]:=horizontal[style];
>MEM[$B800:offset+x*2+1]:=back*16+fore;
>   END;
>   MEM[$B800:offset+(width-1)*2]:=top_right_corner[style];
>   MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
>   FOR y:=1 TO (height-2) DO
>   BEGIN
>MEM[$B800:offset+y*160]:=vertical[style];
>MEM[$B800:offset+y*160+1]:=back*16+fore;
>MEM[$B800:offset+(width-1)*2+y*160]:=vertical[style];
>MEM[$B800:offset+(width-1)*2+y*160+1]:=back*16+fore;
>   END;
>   offset:=(top_left_x-1)*2
>  +(top_left_y+height-2)*160;
>   MEM[$B800:offset]:=bottom_left_corner[style];
>   MEM[$B800:offset+1]:=back*16+fore;
>   FOR x:=1 TO (width-2) DO
>   BEGIN
>MEM[$B800:offset+x*2]:=horizontal[style];
>MEM[$B800:offset+x*2+1]:=back*16+fore;
>   END;
>   MEMW[$B800:offset+(width-1)*2]:=bottom_right_corner[style];
>   MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
>  END;
> END;

If using just unit Crt, you need to call procedures TextColor and
TextBackground for proper setting of your foreground and background colour
("fore" and "back" in your example) and then replace references to Mem on
_even_ addresses (the odd ones are handled automatically by the previous
setting of TextColor and TextBackground) with a combination of GotoXY and
Write calls.

Obviously, it's better to do it in lines (i.e. call GotoXY for the first
character in a sequence of modified characters on that line, then combine
the whole sequence to a string (e.g. starting with "char
(top_left_corner[style])" followed by "width-2" instances of "char
(horizontal[style])" and finally "char (top_right_corner[style])") and
then call Write for the whole created string.

Note that using unit Video is both more efficient and also easier for
translation of your original code.

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Drawing window out line

2014-05-22 Thread Mark Morgan Lloyd

mokashe.ram wrote:

Hi ,

Could Any One help Me  to  writing Horizontal and vertical line to message
window in Free Pascal as i MEM and MEMW function not supported in free
pascal.

note : we can not use Video and CRT Unit both in single unit. i want to use
CRT unit only.

below is the my sample code



  MEM[$B800:offset]:=top_left_corner[style];


I thought it had already been explained to you that you cannot use MEM[] 
etc. on current operating systems, therefore that is not your "sample 
code": it's stuff that you're asking other people to translate for you.


If you want help on this then post a minimal program that compiles but 
exhibits the problem, i.e. ten lines or so that initialises the video 
stuff, tries to write to it (exhibiting the error) and tidies up.


What's going on here? All of a sudden two people start asking very 
similar questions about MEM[], MEMW[] and so on. If this is classwork 
it's probably safe to assume that your instructor is reading this 
mailing list with interest, perhaps he'd like to fill in what operating 
system etc. your code's supposed to run on since you've not told us >:-)


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread ko paka
Hello,

just out of curiosity - by packages do you mean delphi style dynamic
packages - bpl ?

tomas


On Wed, May 21, 2014 at 10:53 PM, Sven Barth wrote:

> Am 21.05.2014 17:53 schrieb "Craig Peterson" :
>
> > I don't mind keeping a fork of a stable release with the feature
> > backported, if that's what it takes, though obviously I'd prefer it to
> > be in properly. Sven, if you're still following the thread, would a
> > bounty help bump the priority enough for you to work on it before the
> > 2.8 cutoff?
>
> While I consider bounties a valuable instrument for Open Source
> development I personally don't like them. Especially in the way you are
> mentioning it (no offence here!) it would put quite some pressure on me
> which I'm honestly not a fan of.
> I don't promise anything - especially since generics and packages are
> higher up on my priority list - but if I find the time...
>
> Regards,
> Sven
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Delphi compatible anonymous functions

2014-05-22 Thread Michael Schnell

On 05/21/2014 05:52 PM, Craig Peterson wrote:
I think it's useful for encapsulating asynchronous callbacks and 
improving readability by keeping the callback code near the setup 
location and removing data marshalling scaffolding.


For complex asynchronous  events, I tested this:

 - Define a class (sibling of TObject) ) that holds some data and the 
procedure to be used in the asynchronous callback. The procedure has no 
parameters


 - To through the callback event, create an instance and fill the data 
structure in the instance and then use TThread.Queue to through the event:

   procedure TmyThread.Execute
   begin
   ...
   AsyncEvent := TAsyncEvent.create;
   AsyncEvent.DataX := .
   AsyncEvent.DataY := .
Queue(AsyncEvent.DoIt);

 - now forget the variable AsyncEvent :-) .

 - some time later the main Thread calls DoIt
  here we go:
  procedure DoIt...
  begin
X := DataX;
Y := DataY;
... do stuff ...
Free;
  end;

  Here, the procedure just frees it's own instance. This does not seem 
to be a problem. (Obviously exception handling needs to be added.)


So I get away without the use of Interfaces.

To me this seems like the most "pascalish" way to implement a "closure" 
for encapsulating asynchronous callbacks.


As syntax candy you might want to define a procedure as having a 
"closure" attribute and have same call free just before exiting (even 
when exiting by an exception).


-Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Drawing window out line

2014-05-22 Thread mokashe.ram
Hi ,

Could Any One help Me  to  writing Horizontal and vertical line to message
window in Free Pascal as i MEM and MEMW function not supported in free
pascal.

note : we can not use Video and CRT Unit both in single unit. i want to use
CRT unit only.

below is the my sample code

PROCEDURE draw_window_outline(top_left_x,
  top_left_y,
  width,
  height,
  style,
  fore,
  back  : BYTE);

VAR
   x,y: BYTE;
   offset : INTEGER;


BEGIN
 IF (style<>255) AND (width>2) AND (height>2) THEN
 BEGIN
  offset:=(top_left_x-1)*2
 +(top_left_y-1)*160;
  MEM[$B800:offset]:=top_left_corner[style];
  MEM[$B800:offset+1]:=back*16+fore;
  FOR x:=1 TO (width-2) DO
  BEGIN
   MEM[$B800:offset+x*2]:=horizontal[style];
   MEM[$B800:offset+x*2+1]:=back*16+fore;
  END;
  MEM[$B800:offset+(width-1)*2]:=top_right_corner[style];
  MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
  FOR y:=1 TO (height-2) DO
  BEGIN
   MEM[$B800:offset+y*160]:=vertical[style];
   MEM[$B800:offset+y*160+1]:=back*16+fore;
   MEM[$B800:offset+(width-1)*2+y*160]:=vertical[style];
   MEM[$B800:offset+(width-1)*2+y*160+1]:=back*16+fore;
  END;
  offset:=(top_left_x-1)*2
 +(top_left_y+height-2)*160;
  MEM[$B800:offset]:=bottom_left_corner[style];
  MEM[$B800:offset+1]:=back*16+fore;
  FOR x:=1 TO (width-2) DO
  BEGIN
   MEM[$B800:offset+x*2]:=horizontal[style];
   MEM[$B800:offset+x*2+1]:=back*16+fore;
  END;
  MEMW[$B800:offset+(width-1)*2]:=bottom_right_corner[style];
  MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
 END;
END;

Thanks, 
Sudarshan



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Drawing-window-out-line-tp5719322.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal