<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
<div id="smartTemplate4-template"><br>
Hi,<br>
<br>
<p>
<blockquote type="cite">
<pre wrap="">It seems you want to emulate pointer of integer.</pre>
</blockquote>
</p>
<p>Of all primitive types<br>
<br>
</p>
<p>In the JavaScript example there was no more integer typing. <br>
</p>
<p><br>
<blockquote type="cite">
<pre wrap="">That would be quite a slow down.</pre>
</blockquote>
</p>
<p>Is it?</p>
<p>I saw no speed difference between<br>
</p>
<p>var x = 1;<br>
for (var i=0;i<100000;i++) x++;<br>
</p>
<p>and</p>
<p>var x = [1];<br>
for (var i=0;i<100000;i++) x[0]++;<br>
<br>
</p>
<p>in Firefox. Perhaps more memory usage<br>
</p>
<p>
<blockquote type="cite">
<pre wrap="">Isn't speed the main idea of using pointers?
</pre>
</blockquote>
</p>
<p>It would be to port all existing pascal code<br>
</p>
<p><br>
<blockquote type="cite">
<pre wrap="">
Also what if var and @var are in different units?</pre>
</blockquote>
</p>
<p>Either it needs full program static analysis, or pointers are
only allowed to something that was used with a pointer in its
unit<br>
</p>
<p>Local pointers (like var arguments) could always be changed to
an array when the address is taken, and copied back at the end
of scope.<br>
</p>
<p><br>
<blockquote type="cite">
<pre wrap="">
And what about pointer of pointer?
</pre>
</blockquote>
<br>
</p>
<p>It becomes an array of arrays with the same construction</p>
<p><br>
</p>
<p>
<blockquote type="cite">
<pre wrap="">You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.
</pre>
</blockquote>
</p>
<br>
That model looks like quite a slow down<br>
<br>
Cheers,<br>
Benito </div>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 17.12.2017 22:24, Mattias Gaertner
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20171217222450.236c4513@limapholos.matflo.wg">
<pre wrap="">On Sun, 17 Dec 2017 21:43:45 +0100
Benito van der Zander <a class="moz-txt-link-rfc2396E" href="mailto:benito@benibela.de"><benito@benibela.de></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
</pre>
<blockquote type="cite">
<pre wrap="">
Naturally, any memory pointer operation is not possible in Javascript.
Code that relies on this will not work.
</pre>
</blockquote>
<pre wrap="">
it would be great, if pointers were added.
</pre>
</blockquote>
<pre wrap="">
There are pointers already. For example references to class and
arrays.
It seems you want to emulate pointer of integer.
</pre>
<blockquote type="cite">
<pre wrap="">One trick would be to wrap every variable that is accessed by a pointer
in an array (or object).
</pre>
</blockquote>
<pre wrap="">
That would be quite a slow down.
Isn't speed the main idea of using pointers?
Also what if var and @var are in different units?
And what about pointer of pointer?
You may want to take a look at asm.js, which has a working
model for emulating pointers in JavaScript. It would be possible to add
a pas2js target for that. But then again there is webassembly
as well and it seems to have better support.
Mattias
_______________________________________________
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>