[Pas2js] TJSXMLHttpRequest questions

Sven Barth pascaldragon at googlemail.com
Sun May 20 14:52:41 CEST 2018


Am 20.05.2018 um 14:16 schrieb Ryan Joseph:
>
>> On May 20, 2018, at 5:51 PM, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>>
>> There are no anonymous methods yet, but there are closures:
>>
>> procedure Test;
>> var
>>   xhr : TJSXMLHttpRequest;
>>
>>   procedure HandleLoaded;
>>   begin
>>     if (xhr.readyState = 4) or (xhr.status = 200) then
>>       writeln(xhr.responseText);
>>   end;
>>
>> begin
>>   xhr := TJSXMLHttpRequest.new;
>>   xhr.open('GET', 'file.html');
>>   xhr.onreadystatechange := @HandleLoaded;
>>   xhr.send;
>> end;
> I thought closures were what FPC was calling anonymous methods. That’s a pretty important feature for JavaScript.
Anonymous functions is how Delphi's syntax for implementing closures is 
called. However the idea is to also support nested functions for 
closures as some might not be fans of Delphi's syntax (which does indeed 
look rather verbose and disruptive).

Regards,
Sven


More information about the Pas2js mailing list