14.xhtml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. h t t :: / / t /
  4. h t t :: // // t //
  5. h ttttt ttttt ppppp sssss // // y y sssss ttttt //
  6. hhhh t t p p s // // y y s t //
  7. h hh t t ppppp sssss // // yyyyy sssss t //
  8. h h t t p s :: / / y .. s t .. /
  9. h h t t p sssss :: / / yyyyy .. sssss t .. /
  10. <https://y.st./>
  11. Copyright © 2016 Alex Yst <mailto:copyright@y.st>
  12. This program is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program. If not, see <https://www.gnu.org./licenses/>.
  22. -->
  23. <!DOCTYPE html>
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <base href="https://y.st./en/weblog/2016/01-January/14.xhtml" />
  27. <title>\GMP &lt;https://y.st./en/weblog/2016/01-January/14.xhtml&gt;</title>
  28. <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
  29. <link rel="stylesheet" type="text/css" href="/link/basic.css" />
  30. <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
  31. <script type="text/javascript" src="/script/javascript.js" />
  32. <meta name="viewport" content="width=device-width" />
  33. </head>
  34. <body>
  35. <nav>
  36. <p>
  37. <a href="/en/">Home</a> |
  38. <a href="/en/a/about.xhtml">About</a> |
  39. <a href="/en/a/contact.xhtml">Contact</a> |
  40. <a href="/a/canary.txt">Canary</a> |
  41. <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
  42. <a href="/en/opinion/">Opinions</a> |
  43. <a href="/en/coursework/">Coursework</a> |
  44. <a href="/en/law/">Law</a> |
  45. <a href="/en/a/links.xhtml">Links</a> |
  46. <a href="/en/weblog/2016/01-January/14.xhtml.asc">{this page}.asc</a>
  47. </p>
  48. <hr/>
  49. <p>
  50. Weblog index:
  51. <a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
  52. <a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
  53. <a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
  54. </p>
  55. <hr/>
  56. <p>
  57. Jump to entry:
  58. <a href="/en/weblog/2015/03-March/07.xhtml">&lt;&lt;First</a>
  59. <a rel="prev" href="/en/weblog/2016/01-January/13.xhtml">&lt;Previous</a>
  60. <a rel="next" href="/en/weblog/2016/01-January/15.xhtml">Next&gt;</a>
  61. <a href="/en/weblog/latest.xhtml">Latest&gt;&gt;</a>
  62. </p>
  63. <hr/>
  64. </nav>
  65. <header>
  66. <h1><code>\GMP</code></h1>
  67. <p>Day 00313: Thursday, 2016 January 14</p>
  68. </header>
  69. <p>
  70. The spider continues to make slow progress, but it is still moving along.
  71. I built a simple script for listing the currently-known onions.
  72. I soon found that there was a problem with <a href="https://notabug.org/y.st./include.d">include.d</a> that prevents my website from compiling though, so I had to turn my attention to building another wrapper class so that I could push another update.
  73. </p>
  74. <p>
  75. Today&apos;s wrapper class was for use with the <a href="https://secure.php.net/manual/en/ref.image.php"><abbr title="graphics draw">GD</abbr> and image functions</a>.
  76. Mostly, everything went well, but there was one function that I was not going to implement at first.
  77. Apparently, it makes use of a <a href="http://php.net/manual/en/book.com.php">Windows-only extension</a>.
  78. I thought that implementing it in my wrapper class would require building a wrapper class for some Windows-only functions, which is not at all worth my time and energy.
  79. However, it turns out that the extension already defines its own class.
  80. Instead of having to define a whole unusable wrapper class to implement this one function as a method, I only needed to write two lines of code, so I went ahead and implemented it.
  81. It felt like it might be a bit spiteful to not implement it when implementing it was so easy.
  82. There were several functions that were removed in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> 7 though, so I left them out as code will need to migrate away from these functions anyway if they want to be future-proof.
  83. </p>
  84. <p>
  85. After finishing that wrapper class, I took a look at what wrapper class I would be working on next time.
  86. I found that the next one on the list is the one for the <abbr title="GNU&apos;s Not Unix">GNU</abbr> multiple precision extension.
  87. This extension is set up very poorly indeed.
  88. It already uses objects, but these objects have no methods.
  89. As the <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> manual puts it, <a href="https://secure.php.net/manual/en/class.gmp.php"><q>Note: No object oriented interface is provided to manipulate GMP objects.
  90. Please use the procedural GMP API.</q></a>.
  91. I started working on some initial tests to see if I would be able to extend this class when building my wrapper class, and I found some very strange results.
  92. <code>\GMP</code> objects have a strange ability that allows them to behave as numbers.
  93. For example, you can use them in mathematical equations.
  94. There does not seem to be a way to implement this capability without extending the <code>\GMP</code> class, but extending this class does not allow one to set the number that the object is to act like.
  95. Instead, the number is stuck at zero.
  96. At first, it seemed that the class was using some strange, unsettable property.
  97. This property is visible when using <code>\var_dump()</code>, but all attempts to change it are ineffective.
  98. However, after further testing, I found that this property seems to exist on some other layer of the object.
  99. Attempts to read this property before setting it result in an error message about the property not existing, but attempts to read the property <strong>*after*</strong> setting it result in the value you set being read back.
  100. However, <code>\var_dump()</code> does not show the value that is being read from and written to.
  101. Instead, it shows the value of the property overlaid from the other layer.
  102. The reason that I cannot set this value is not necessarily because it it is read-only, but because I cannot reach it.
  103. Further reading of the documentation revealed something else as well.
  104. The functions that operate on these objects, the ones that I thought should have been included as methods of the class that they operate on, do not modify the objects they work on.
  105. instead, they return new instances of the class.
  106. This alone would be implementable in my wrapper class, but the overlaid property and the capability to use instances as numbers are not something that I can duplicate.
  107. I decided not to wrap the functions simply because there was no way to do so without losing the class&apos; special feature.
  108. </p>
  109. <p>
  110. People complain about <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> due to things that they do not like about how it works on the surface, though those things do not bother me too much.
  111. Instead, it is these deeper-level things that bother me.
  112. <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> is allowed to define classes that behave differently than user-defined classes are allowed to behave.
  113. This, to me, makes the language feel a bit inconsistent.
  114. If a feature were unavailable to classes across the board, it would mean that <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> objects simply do not behave that way.
  115. Having classes with these &quot;special&quot; features that are unavailable to other objects makes those classes feel less like actual classes, and more like something that someone cobbled together to fill a certain need without regard to the fact that other people might have similar yet different needs.
  116. </p>
  117. <p>
  118. My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
  119. </p>
  120. <hr/>
  121. <p>
  122. Copyright © 2016 Alex Yst;
  123. You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
  124. If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
  125. My address is in the source comments near the top of this document.
  126. This license also applies to embedded content such as images.
  127. For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
  128. </p>
  129. <p>
  130. <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
  131. This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F01-January%2F14.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F01-January%2F14.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
  132. </p>
  133. </body>
  134. </html>