12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- /**
- * <https://y.st./>
- * Copyright © 2016 Alex Yst <mailto:copyright@y.st>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org./licenses/>.
- **/
- $xhtml = array(
- 'title' => '<code>\\GMP</code>',
- 'body' => <<<END
- <p>
- The spider continues to make slow progress, but it is still moving along.
- I built a simple script for listing the currently-known onions.
- 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.
- </p>
- <p>
- Today'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>.
- Mostly, everything went well, but there was one function that I was not going to implement at first.
- Apparently, it makes use of a <a href="http://php.net/manual/en/book.com.php">Windows-only extension</a>.
- 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.
- However, it turns out that the extension already defines its own class.
- 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.
- It felt like it might be a bit spiteful to not implement it when implementing it was so easy.
- 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.
- </p>
- <p>
- After finishing that wrapper class, I took a look at what wrapper class I would be working on next time.
- I found that the next one on the list is the one for the $a[GNU] multiple precision extension.
- This extension is set up very poorly indeed.
- It already uses objects, but these objects have no methods.
- 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.
- Please use the procedural GMP API.</q></a>.
- 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.
- <code>\\GMP</code> objects have a strange ability that allows them to behave as numbers.
- For example, you can use them in mathematical equations.
- 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.
- Instead, the number is stuck at zero.
- At first, it seemed that the class was using some strange, unsettable property.
- This property is visible when using <code>\\var_dump()</code>, but all attempts to change it are ineffective.
- However, after further testing, I found that this property seems to exist on some other layer of the object.
- 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.
- However, <code>\\var_dump()</code> does not show the value that is being read from and written to.
- Instead, it shows the value of the property overlaid from the other layer.
- The reason that I cannot set this value is not necessarily because it it is read-only, but because I cannot reach it.
- Further reading of the documentation revealed something else as well.
- 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.
- instead, they return new instances of the class.
- 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.
- I decided not to wrap the functions simply because there was no way to do so without losing the class' special feature.
- </p>
- <p>
- 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.
- Instead, it is these deeper-level things that bother me.
- $a[PHP] is allowed to define classes that behave differently than user-defined classes are allowed to behave.
- This, to me, makes the language feel a bit inconsistent.
- If a feature were unavailable to classes across the board, it would mean that $a[PHP] objects simply do not behave that way.
- Having classes with these "special" 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.
- </p>
- <p>
- My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
- </p>
- END
- );
|