Recent

Author Topic: tthread code tthread.create/tthread,execute/constructor  (Read 6052 times)

toby

  • Sr. Member
  • ****
  • Posts: 251
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #30 on: August 05, 2019, 01:48:17 am »
mr-highball

Ah now it clicks what is going on - generics is in 3.1.1 and this is the latest coding stuff - so should i stay up to date with the fgl.pp from trunk or is what is in the 3.1.1 okay for this current/future generics? I can just update the fgl.pp unit right when i notice changes?

https://wiki.freepascal.org/Generics

https://forum.lazarus.freepascal.org/index.php/topic,45818.75.html

btw i realized it was the fgl.pp unit that was giving the hints i was just wondering if it affected what you were coding or limited in what you could code in the ezthreads

---

i see what is happening to the links - i usually use dillo (with no javascript) to do stuff and only seamonkey (javascript) to post
the links are changed by javascript to go to where the link says it is - there is some tracking code in the link


mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #31 on: August 05, 2019, 01:59:28 am »
toby, you should be good with 3.1.1+ since I coded this on stable (3.0.4) and have tested it with the latest trunk (3.3.1) (didn't seem to have any major breaking changes).
I plan to keep compliant with 3.0.4 generics for the foreseeable future, but I may add support for the Generics.Collections unit if I do any future work to expand the library (probably implementing more functional methods).

Hope this helps, and if you care to see any particular examples, I'd be glad to write some.

toby

  • Sr. Member
  • ****
  • Posts: 251
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #32 on: August 05, 2019, 02:14:26 am »
mr-highball

if i might suggest why don't you start a new topoc   "Generics" and repost your

https://forum.lazarus.freepascal.org/index.php/topic,45818.75.html

as first post

or does everyone know that generics is functional programming ?

https://en.wikipedia.org/wiki/Generic_programming     needs ^h^h^h^h^h has a nice fpc section for sure



« Last Edit: August 05, 2019, 02:17:30 am by toby »

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #33 on: August 05, 2019, 02:45:09 am »
I thought about posting a new topic for it, but I currently only have one of the functional methods implemented out of the ones listed from that topic's original post:

Are there functional programming methods in Pascal such as map, filter, apply, reduce, fold, foldl and foldr function? I could not find them on searching the internet. Possibly Pascal is a purely imperative language.

If not, is it possible to create a map function so that one can sent a list/array to it with a function and it return a new list/array with sent function applied to each element of sent list:

Code: Pascal  [Select][+][-]
  1. outlist := map(sentfunction, sentlist);

where sentfunction is a function which takes only one item and returns a modified item.

I'll probably throw something in the "third party" section once I get a few more examples out of the way so people can see some use cases


toby

  • Sr. Member
  • ****
  • Posts: 251
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #34 on: August 05, 2019, 03:13:19 am »
'general' might be a good place just to get something for discussion

i see you are using delphi style for the ''map' and delphi mode for the ezthreads ? are there benefits of one over the other for the generics?

are you on a windows system?



mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #35 on: August 05, 2019, 03:23:40 am »
For me, the delphi generic syntax is preferable since I find it to be more simplified. In addition, if I wanted to port what I write cross-compiler, the delphi mode offers the easiest way to do so.

General probably is a better place to start something, so I'll most likely post something that way once I implement a few more method (sort, filter, etc...)

toby

  • Sr. Member
  • ****
  • Posts: 251
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #36 on: August 05, 2019, 03:49:07 am »

i tried to compile the map example and got
ezthreads.functional.pas(141,3) Error: Compilation raised exception internally

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #37 on: August 05, 2019, 03:59:08 am »
The functional unit needs the latest trunk (3.3.1) to properly work, is that what you are using? If so what operating system?
(I also wrote it pretty quickly... So there are probably bugs)

toby

  • Sr. Member
  • ****
  • Posts: 251
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #38 on: August 05, 2019, 04:19:04 am »
i have 3.1.1 on linux

i should have known you were on windows when i had to add cthreads manually to ezthreads_tester_ui.lpr (the programs ifdef unix didn't work)
3.1.1 compiles it fine and it runs fine

the 'map'   ezthreads_tester_functional.lpr requires 3.3.1





PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: tthread code tthread.create/tthread,execute/constructor
« Reply #39 on: August 05, 2019, 09:20:48 am »
The functional unit needs the latest trunk (3.3.1) to properly work, is that what you are using? If so what operating system?
(I also wrote it pretty quickly... So there are probably bugs)
Did you also test with the upcoming 3.2? After all that's going to be the next major release containing generic functions as well.

 

TinyPortal © 2005-2018