14.xhtml 5.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * <https://y.st./>
  4. * Copyright © 2016 Alex Yst <mailto:copyright@y.st>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org./licenses/>.
  18. **/
  19. $xhtml = array(
  20. 'title' => '<code>\\GMP</code>',
  21. 'body' => <<<END
  22. <p>
  23. The spider continues to make slow progress, but it is still moving along.
  24. I built a simple script for listing the currently-known onions.
  25. 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.
  26. </p>
  27. <p>
  28. Today&apos;s wrapper class was for use with the <a href="https://secure.php.net/manual/en/ref.image.php">$a[GD] and image functions</a>.
  29. Mostly, everything went well, but there was one function that I was not going to implement at first.
  30. Apparently, it makes use of a <a href="http://php.net/manual/en/book.com.php">Windows-only extension</a>.
  31. 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.
  32. However, it turns out that the extension already defines its own class.
  33. 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.
  34. It felt like it might be a bit spiteful to not implement it when implementing it was so easy.
  35. There were several functions that were removed in $a[PHP] 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.
  36. </p>
  37. <p>
  38. After finishing that wrapper class, I took a look at what wrapper class I would be working on next time.
  39. I found that the next one on the list is the one for the $a[GNU] multiple precision extension.
  40. This extension is set up very poorly indeed.
  41. It already uses objects, but these objects have no methods.
  42. As the $a[PHP] 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.
  43. Please use the procedural GMP API.</q></a>.
  44. 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.
  45. <code>\\GMP</code> objects have a strange ability that allows them to behave as numbers.
  46. For example, you can use them in mathematical equations.
  47. 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.
  48. Instead, the number is stuck at zero.
  49. At first, it seemed that the class was using some strange, unsettable property.
  50. This property is visible when using <code>\\var_dump()</code>, but all attempts to change it are ineffective.
  51. However, after further testing, I found that this property seems to exist on some other layer of the object.
  52. 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.
  53. However, <code>\\var_dump()</code> does not show the value that is being read from and written to.
  54. Instead, it shows the value of the property overlaid from the other layer.
  55. The reason that I cannot set this value is not necessarily because it it is read-only, but because I cannot reach it.
  56. Further reading of the documentation revealed something else as well.
  57. 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.
  58. instead, they return new instances of the class.
  59. 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.
  60. I decided not to wrap the functions simply because there was no way to do so without losing the class&apos; special feature.
  61. </p>
  62. <p>
  63. People complain about $a[PHP] due to things that they do not like about how it works on the surface, though those things do not bother me too much.
  64. Instead, it is these deeper-level things that bother me.
  65. $a[PHP] is allowed to define classes that behave differently than user-defined classes are allowed to behave.
  66. This, to me, makes the language feel a bit inconsistent.
  67. If a feature were unavailable to classes across the board, it would mean that $a[PHP] objects simply do not behave that way.
  68. 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.
  69. </p>
  70. <p>
  71. My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
  72. </p>
  73. END
  74. );