Recent

Author Topic: [Don't bother to read it] in D code while convertering over to Fpc/laz code.  (Read 1311 times)

jamie

  • Hero Member
  • *****
  • Posts: 6077
I found in a few places of anonymous methods being implemented within the (  …) of a CreateTask call

Example..

 CreateTask(Procdure Begin...code.. end).ThenAmemberField
                                                            .AnotherIdentifier;
                                                            .AndstilAnother;

The point is if you noticed the "." at the start of those fields with nothing leading up to the "." ?

 What exactly is that doing here ?

 Is that a shortcut way to address members of  createTask ?
« Last Edit: October 23, 2020, 02:50:14 am by jamie »
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Are you sure it's ";" at the end and not simply nothing like after ThenAmemberField? Maybe better show a real example.

jamie

  • Hero Member
  • *****
  • Posts: 6077
no I may have had the ; at the ends incorrect but here is a piece of code
Code: Pascal  [Select][+][-]
  1.    CreateTask(WriteStreamToPlayer)
  2.     .OnMessage(TaskMessageProc)
  3.     .SetParameter('item', itm)
  4.     .Unobserved
  5.     .Schedule;                  
  6.  

The CreateTask Returns an Iinterface and all those members are part of it.

code tools in lazarus seems to be able to pickup on this but i have not yet got to a successful compile up to that code yet so I don't know if that will actually compile.?

 if this is legal code then how long as this been in there ?
The only true wisdom is knowing you know nothing

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11353
  • FPC developer.
Then syntax is old. Turbo Vision used it a lot, both in Pascal and C++.

But the trick is the defering of running till the task is finalized (which I assume onmessage does), not the bare syntax

jamie

  • Hero Member
  • *****
  • Posts: 6077
ok, false alarm...

 Apparently each one of those calls are functions which return a object that has a member that is again another function. so its  long chain list of functions..

So its a deep Tree of functions that start from CreateTast.....

Ok.

I'll close this as a visual deception of code I was looking at.
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Apparently each one of those calls are functions which return a object that has a member that is again another function. so its  long chain list of functions..

That's exactly what I thought, which is why I asked about the semicolon.

 

TinyPortal © 2005-2018