123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?xml version="1.0" encoding="utf-8"?>
- <!--
-
- h t t :: / / t /
- h t t :: // // t //
- h ttttt ttttt ppppp sssss // // y y sssss ttttt //
- hhhh t t p p s // // y y s t //
- h hh t t ppppp sssss // // yyyyy sssss t //
- h h t t p s :: / / y .. s t .. /
- h h t t p sssss :: / / yyyyy .. sssss t .. /
-
- <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/>.
- -->
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <base href="https://y.st./en/weblog/2016/01-January/14.xhtml" />
- <title>\GMP <https://y.st./en/weblog/2016/01-January/14.xhtml></title>
- <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
- <link rel="stylesheet" type="text/css" href="/link/basic.css" />
- <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
- <script type="text/javascript" src="/script/javascript.js" />
- <meta name="viewport" content="width=device-width" />
- </head>
- <body>
- <nav>
- <p>
- <a href="/en/">Home</a> |
- <a href="/en/a/about.xhtml">About</a> |
- <a href="/en/a/contact.xhtml">Contact</a> |
- <a href="/a/canary.txt">Canary</a> |
- <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
- <a href="/en/opinion/">Opinions</a> |
- <a href="/en/coursework/">Coursework</a> |
- <a href="/en/law/">Law</a> |
- <a href="/en/a/links.xhtml">Links</a> |
- <a href="/en/weblog/2016/01-January/14.xhtml.asc">{this page}.asc</a>
- </p>
- <hr/>
- <p>
- Weblog index:
- <a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
- <a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
- <a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
- </p>
- <hr/>
- <p>
- Jump to entry:
- <a href="/en/weblog/2015/03-March/07.xhtml"><<First</a>
- <a rel="prev" href="/en/weblog/2016/01-January/13.xhtml"><Previous</a>
- <a rel="next" href="/en/weblog/2016/01-January/15.xhtml">Next></a>
- <a href="/en/weblog/latest.xhtml">Latest>></a>
- </p>
- <hr/>
- </nav>
- <header>
- <h1><code>\GMP</code></h1>
- <p>Day 00313: Thursday, 2016 January 14</p>
- </header>
- <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"><abbr title="graphics draw">GD</abbr> 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 <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.
- </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 <abbr title="GNU's Not Unix">GNU</abbr> multiple precision extension.
- This extension is set up very poorly indeed.
- It already uses objects, but these objects have no methods.
- 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.
- 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 <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.
- Instead, it is these deeper-level things that bother me.
- <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> 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 <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> 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>
- <hr/>
- <p>
- Copyright © 2016 Alex Yst;
- 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's Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
- If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
- My address is in the source comments near the top of this document.
- This license also applies to embedded content such as images.
- For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
- </p>
- <p>
- <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
- 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.
- </p>
- </body>
- </html>
|