Re: [PHP-DEV] Native Annotation Syntax

2015-11-24 Thread Rowan Collins
tation just a string, or a parseable PHP expression? is it more useful to use the de facto existing syntax in DocBlocks, or to add a new keyword or operator? etc The devil, as ever, is in the detail. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List T

[PHP-DEV] Re: Internal methods proposal

2015-11-24 Thread Rowan Collins
this list, to make it easier to find what has previously been discussed on a topic. Regards, -- Rowan Collins [IMSoP] Ah yes, I've seen them in the request bugs. https://bugs.php.net/bug.php?id=52297 It was suggested that a prototype be made, I have provided one, and it should pass basic

Re: [PHP-DEV] Internal methods proposal

2015-11-24 Thread Rowan Collins
terms such as "package visibility", "namespace visibility", "private class", and the related notion of "friend class" / "friend function". I wonder if we should maintain a Usenet-style FAQ for this list, to make it easier to find what has previously

Re: [PHP-DEV] Re: Resource typehint and return type

2015-11-23 Thread Rowan Collins
ou can normally limit their use with careful design. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: Resource typehint and return type

2015-11-23 Thread Rowan Collins
ising. More contentious is how is_resource() should behave; assuming *all* resources are converted, it could just be deprecated anyway, I guess... Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: Resource typehint and return type

2015-11-23 Thread Rowan Collins
ng currently returning a resource cannot be changed without declaring a breaking change. And if you're changing fgets but not fopen, you might as well just build a new API, which SplFileObject already has most of (for some reason, it appears to include fputcsv but not fputs). Regards, --

Re: [PHP-DEV] Immutable modifier

2015-11-17 Thread Rowan Collins
duced. That said, I'd be interested in examples of what any other languages do around this area, and how it is used in practice. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Immutable modifier

2015-11-17 Thread Rowan Collins
ility and robustness) rather outweigh the gains of marking the class immutable, if the implementation is such that you're forced to choose. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Immutable modifier

2015-11-17 Thread Rowan Collins
nce you've set it up, or have privileged (private) methods which are allowed to mutate the properties. [1] https://github.com/guzzle/psr7/blob/master/src/Request.php#L101 Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Immutable modifier

2015-11-16 Thread Rowan Collins
essary. The ability to freeze an array would also be useful in that case... I realise this is a lot more complex than the original suggestion, but I think something of this level of detail is needed to make it useful. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Null bytes in anonymous class names

2015-11-11 Thread Rowan Collins
Steven Hilder wrote on 11/11/2015 02:13: This behaviour was present in Joe's original implementation, but later removed[3] by Nikita. His commit message says that this was "dead code", but I don't see what was wrong with it. It looks to me like 'decl->name' will never be set for an anonymous

Re: [PHP-DEV] Null bytes in anonymous class names

2015-11-05 Thread Rowan Collins
private members [e.g. https://3v4l.org/R6Y6k] In this case, I guess the "@" in "class@anonymous" makes the name illegal anyway, but I'm not sold on the null byte being more unacceptable here than anywhere else. Regards, -- Rowan Collins [IMSoP] -- PHP Internals -

Re: [PHP-DEV] [Question] Variadic method signature compatibility between 5.6 and 7.0

2015-11-03 Thread Rowan Collins
Rowan Collins wrote on 03/11/2015 09:20: That's not equivalent, because the version with no arguments explicitly prohibits zero arguments, which the variadic signature doesn't. Sorry, this should read "the version with no arguments explicitly prohibits passing one argu

Re: [PHP-DEV] [Question] Variadic method signature compatibility between 5.6 and 7.0

2015-11-03 Thread Rowan Collins
Marc Bennewitz wrote on 02/11/2015 19:44: Hi Rowan, On 11/02/2015 05:41 PM, Rowan Collins wrote: Alexander Lisachenko wrote on 02/11/2015 11:12: First definition declares exactly one single parameter, which can be absent during the method call, so I can even write public static function

Re: [PHP-DEV] [Question] Variadic method signature compatibility between 5.6 and 7.0

2015-11-02 Thread Rowan Collins
agree with you that this warning is incorrect, but will leave this here in case anybody else is equally confused (and becomes any less so by reading this...) Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: Friend class/function

2015-11-02 Thread Rowan Collins
data, but named in a way that was likely to deter use. Would "package" (namespace-based) visibility have solved the problem in this case? That's something I've often wanted - "this is public within this Lib, but should never be used outside it". Regards, --

Re: [PHP-DEV] [Question] Variadic method signature compatibility between 5.6 and 7.0

2015-11-02 Thread Rowan Collins
ction signature that Foo specifies, so the warning seems perfectly correct to me. In your example, you've replaced a single optional parameter ($bar = null) with a specification of variadic parameters (...$args); these are clearly not interchangeable, so again, the signature is different.

Re: [PHP-DEV] In a destructor, how to detect if an exception is currently in flight?

2015-10-29 Thread Rowan Collins
Johannes Schlüter wrote on 28/10/2015 22:56: On Wed, 2015-10-28 at 16:45 +, Rowan Collins wrote: On the downside, it's worth noting that while PHP destructors are technically deterministic, the language can actually prevent them running on scope exit, because Exceptions hold referenc

Re: [PHP-DEV] In a destructor, how to detect if an exception is currently in flight?

2015-10-28 Thread Rowan Collins
Erik van Velzen wrote on 28/10/2015 15:02: The ScopeGuard's destructor can now detect the condition: if ( $this->success_registered ) { // Function reached checkpoint for this scope $this->callSuccessHandlers(); } else { // Function aborted early, due to a throw or early return $

Re: [PHP-DEV] In a destructor, how to detect if an exception is currently in flight?

2015-10-28 Thread Rowan Collins
lExitHandlers(); No boilerplate throw-catch needed, works even if there is already a catch or finally within the function's definition. In fact, I kind of want to use this somewhere now... ;) Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
d like to say that although the documentation is official, I think it should be considered descriptive not prescriptive - if it labels something as void, but the Engine doesn't consider it so, the manual would be wrong, not the Engine. Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
Andrea Faulds wrote on 15/10/2015 17:34: Hi Pedro, Pedro Cordeiro wrote: I've been thinking about what PHP should do when accessing the return value of a `void` function, and so far, I think the consistent thing should be to get NULL, while throwing an E_NOTICE. We could do this, but I do w

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
know whether a return value is being used or discarded for optimisation purposes? If so, could that logic be hooked to provide the Notice? Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
Andrea Faulds wrote on 15/10/2015 16:32: Hi Rowan, Rowan Collins wrote: But why "invent" (as far as PHP is concerned) this new keyword of "void" to mean exactly the same thing "null" already means - absence of a definite value? They don't mean exactly

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
r could detect the discrepancy, but the Zend Engine will not, until the function is executed. It's a shame there's no "tail call this other function and discard its result" construct. Yeah, I guess what you really want is for a void function to be able to "goto foo();

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
gate: function foo(): void { do_something(); } function wrapped_foo(): void { do_something_else(); return foo(); } // ERROR: can't specify return value in a void function "return foo()" is not illegal because foo is declared void, but because wrapped_foo is - even though the result is

Re: [PHP-DEV] [RFC] Void Return Type (v0.2, reöpening)

2015-10-15 Thread Rowan Collins
Korvin Szanto wrote on 14/10/2015 23:55: If I capture the result of a "void" method and check if my result variable with isset(), I'll get false. This sounds like it's void of value to me. But why "invent" (as far as PHP is concerned) this new keyword of "void" to mean exactly the same thing "

Re: [PHP-DEV] Port random_bytes to PHP 5

2015-10-13 Thread Rowan Collins
ore you backport, the more you fragment the ecosystem. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Scalar type hints and scalar type name aliases causeconfuson

2015-10-13 Thread Rowan Collins
is more useful if we don't make everything alias. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] RFC proposal.

2015-10-05 Thread Rowan Collins
re, or could it just be a lightweight Composer dependency people could grab when they needed it? [1] https://en.m.wikipedia.org/wiki/Binary_prefix Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] [DRAFT]: Consistent callables

2015-10-05 Thread Rowan Collins
nctionality is available to move to) rather than leaving until the last minute; and b) we won't necessarily know that a particular release is 7.last, e.g. the decision against releasing a 5.7 happened 6 months after the release of 5.6.0 Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [RFC] Arrow Functions

2015-10-05 Thread Rowan Collins
Tom Worster wrote on 03/10/2015 21:33: when the grammar starts with function(args), it seems the main difference from existing grammar is to make the curly braces when there's only one statement in the function block. in other contexts i had the impression that things like if (bool-expr)

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
Levi Morrison wrote on 01/10/2015 19:09: You are capped to saving about 5-7 characters no matter what you do with this functionality. I see an upper limit to savings of 21 - using "|" to stand in for "some single character delimiting the sections" gives: |$x|$y|$x*$y| // 13 chars vs functi

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
when that would be required. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
ntax in general) but are happy with the *functionality*. You are assuming that "I think the current syntax is verbose" is synonymous with "I think having to list captured variables is annoying", but there are people who do not take that position. Regards, -- Rowan Collins -- PHP Int

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
Nikita Nefedov wrote on 01/10/2015 15:58: On Thu, 01 Oct 2015 15:33:51 +0300, Rowan Collins wrote: It is a tool for making them shorter, yes, but it is not the only way, and it comes with a cost of changing established behaviour. Again, look at C++'s lambda syntax - it is much shorter

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
rather than 3. Genuine question, not a criticism - this functional(?) style of composition is not something I'm very familiar with. (For the same reason, I struggle to read that function definition no matter which syntax it's expressed in.) Regards, -- Rowan Collins [IMSoP] -- PHP

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
. Whereas with auto capture you can at least guess that this variable will be captured from defining scope, if you don't know how this feature works). Well, you certainly can't guess it from the behaviour of anything else in PHP. You could guess based on the behaviour of other lang

Re: [PHP-DEV] Arrow function expressions in PHP

2015-10-01 Thread Rowan Collins
tly reasonable to want both a shorter syntax and a different capture behaviour; but it also seems perfectly reasonable to want a shorter syntax with the same functionality as the current one, just as we have with [] vs array(). Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP

Re: [PHP-DEV] Arrow function expressions in PHP

2015-09-30 Thread Rowan Collins
] for array construction. But it does show that "short closures" and "auto-capture closures" are two different features; we could save up to 17 characters without changing behaviour if we could eliminate the keywords "function", "use", and "return". Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Arrow function expressions in PHP

2015-09-30 Thread Rowan Collins
a mug's game to guess which factors influence whom. Also, remember that the votes on RFCs are intended to confirm consensus, not replace it - the idea is not to win over just enough people to "win", so it's not necessarily about numbers. That's not to say that automatic ca

Re: [PHP-DEV] async/await - is future reserved words in PHP 7.x?

2015-09-29 Thread Rowan Collins
as multiple CPU cores. An asynchronous approach is useful for cases of "do something else while I wait for this background task to complete", but seems less so for "do both of these things actively, using whatever resource is available". It may be that the first class of

Re: [PHP-DEV] Arrow function expressions in PHP

2015-09-26 Thread Rowan Collins
x) { $x * 2 } lambda($x) { $x * 2 } Or the arrow inside the parens: fn($x => $x * 2) function($x => $x * 2) My point is that there are plenty of other variants, if we're no longer mimicking the "(params) => expression" syntax of other languages. Regards, -- Rowan Colli

Re: [PHP-DEV] Arrow function expressions in PHP

2015-09-26 Thread Rowan Collins
eady been raised: function($x) use ($y) { foo($x); bar($x, $y); } fn($x) => { foo($x); bar($x, $y); } Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Wiki RFC karma request: imsop

2015-09-26 Thread Rowan Collins
Hi, I would like to write up my suggestion of hasitem() and variable_exists() as a formal RFC. I have registered on the wiki with username "imsop", please could I have appropriate karma to draft the RFC. Cheers, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Developme

Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-24 Thread Rowan Collins
least) being that a structure is passed around via TSRM* macros and ultimately used by the EG macro in place of a true global: http://lxr.php.net/xref/PHP_5_6/Zend/zend_globals_macros.h#45 All of this is something of an aside from what you really wanted to know, though. :) Regards, -- Rowan

Re: [PHP-DEV] Re: [RFC] [VOTE] Short Closures

2015-09-24 Thread Rowan Collins
ink it's a big problem myself, but I can see the logic of questioning it. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-24 Thread Rowan Collins
Rowan Collins wrote on 23/09/2015 21:15: On 23 September 2015 20:04:57 BST, Ryan Pallas wrote: I dislike this because it makes refactoring harder. What's more, the function is not dereferencing a variable to get its value, it is looking up a name in the symbol table, so the magic syntax

Re: [PHP-DEV] Re: [RFC] [VOTE] Short Closures

2015-09-24 Thread Rowan Collins
Lester Caine wrote on 24/09/2015 08:06: So is PHP heading down the path of a compiled language even if that is hidden in some automatic cache or is it still mainly an interpreted script? PHP already is a compiled language; it just has a highly dynamic runtime engine (which is at times a blessi

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-24 Thread Rowan Collins
proposed function definition is also very all-inclusive, leading to the risk of hard-to-understand code. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Data serialization of objects, want to iterate 'sealed' properties then dynamic ones

2015-09-23 Thread Rowan Collins
arge caveats, and uses specific objects to communicate between threads. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
e using the variable is misleading. And yes, the same criticism is true of hasitem(); I'm not 100% sure if it's a good idea or not, only that it's preferable to a Swiss-army knife exists(). Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
Lester Caine wrote on 23/09/2015 18:15: On 23/09/15 17:37, Stig Bakken wrote: I'm still in favor of having a variable_exists('varname') function though. We had it ... https://bugs.php.net/bug.php?id=24274 Actually that looks like what is currently being proposed as exists() - a swiss-army k

Re: [PHP-DEV] Re: Let's discuss enums!

2015-09-23 Thread Rowan Collins
holds the name and an "ordinal" z_long directly, and only access the object representation if these two pieces of information are not sufficient. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
d vote yes myself, but it would at least allow for more opinions to be recorded. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
the same set of columns but there is nothing demanding that every column in the database is actually returned in every query? Only returning the subset needed for the job is perfectly sensible and there are a number of ways that can happen OK, that makes sense. Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
François Laupretre wrote on 23/09/2015 16:05: Le 23/09/2015 12:18, Rowan Collins a écrit : Clearly, people misunderstand what isset() does, but I think an exists() function which mimics it with a slight difference will only add to that confusion - people will say "oh, if only I had PH

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
established that the null state is a natural result of interaction with a database Indeed, I have never disputed that. A non-existent variable, however, is not something I've ever come across in a database context - it would seem to require a result set having rows with different numbers of col

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
n, variable_exists() would be a function which had a well-defined scope, and obvious how to use it. Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-23 Thread Rowan Collins
: array_key_exists(“var”, get_defined_vars()) && is_null($var) I wondered if someone would mention that, but didn't want to drift too far from the point, which was the "prior to call is_null()" part of Lester's sentence was redundant, since the problem was entirely unrela

Re: [PHP-DEV] Re: Let's discuss enums!

2015-09-22 Thread Rowan Collins
/javase/tutorial/java/javaOO/enum.html [3] http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html [4] https://docs.python.org/3/library/enum.html Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-22 Thread Rowan Collins
o the confusion which isset() already seems to cause. A variable_exists() which took a string (in keeping with class_exists(), function_exists(), etc) would also be more powerful, since you could write things like variable_exists('foo_' . $i) Regards, -- Rowan Collins [IMSoP] -- PH

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-20 Thread Rowan Collins
On 20 September 2015 17:10:23 BST, Lester Caine wrote: >On 20/09/15 15:05, Rowan Collins wrote: >> is_null returns true in all the same situations as isset does. There >is absolutely no difference except for whether it raises a notice. > >? is_null returns true when i

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-20 Thread Rowan Collins
On 20 September 2015 01:43:06 BST, Ryan Pallas wrote: >I would also point out that is_null returns true (after the engine >produces >a notice) for undefined variables: > >$ php -r "var_dump(is_null($a));" > >Notice: Undefined variable: a in Command line code on line 1 > >Call Stack: > 0.0001

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-20 Thread Rowan Collins
completely separate problem from how to avoid the notices. Again, it is not the noise which is stopping your car from flying. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-19 Thread Rowan Collins
On 19/09/2015 22:43, Lester Caine wrote: On 19/09/15 22:22, Rowan Collins wrote: If what you want to do is avoid the notice, then you don't need to "find out before calling is_null", you need to call isset *instead of* is_null. Again, ignore the name, and concentrate on what i

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-19 Thread Rowan Collins
On 19 September 2015 15:49:55 BST, Lester Caine wrote: >On 19/09/15 13:15, Rowan Collins wrote: >If there was a bug with 'isset' it is that it returns false for a >variable that IS SET to null. I honestly think that the only problem there is the name. If instead of isset()

Re: [PHP-DEV] Coding styles ...

2015-09-19 Thread Rowan Collins
th a multi-paradigm language is it becoming "Jack of all trades, master of none", either because the features themselves are sub-standard, or because people use features designed for one style of coding as stand-ins for other styles. e.g. mixing variable variables and object composition is likely to lead to some confusion. Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-19 Thread Rowan Collins
and tempted to give it a "scarier" name Importantly, neither of these should be presented as "fixing isset", since I have seen absolutely zero evidence that it is broken; the names and behaviours are designed to highlight that these are functions to be used for specifi

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-19 Thread Rowan Collins
27;d choose. Every time you start talking about avoiding notices, and existing code, I therefore get confused - there is no code using exists() in order for it to be buggy! Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-19 Thread Rowan Collins
) gives a notice. >IS there another fix for is_null($bar) not throwing a notice if it has >not been created in my example for the current template. Yes, use isset(). Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: htt

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
here is a method to select an instance by value, which will always return the first member with that value, not the alias. The examples also include lots of ways of using the value with overloaded operators etc. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development M

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
On 18 September 2015 18:31:55 BST, Lester Caine wrote: >On 18/09/15 00:06, Rowan Collins wrote: >> So, what are anyone's thoughts? Am I rambling on too much as usual? >;) > >What happens when you need to switch language? Yes, the names of enum members should be

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
be an enum with two - you can define (int)true as 1, but true is not an integer, and 1 is not a boolean value. I suspect both styles may have their place, but algebraic types certainly wouldn't take away my thirst for object-like enums. Regards, -- Rowan Collins [IMSoP] -- PHP Internal

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
for bitsets, which overloaded bitwise operators without ever exposing the underlying integers, might be interesting, though. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: Let's discuss enums!

2015-09-18 Thread Rowan Collins
On 18 September 2015 03:58:57 BST, Stephen Coakley wrote: >On 09/17/2015 06:06 PM, Rowan Collins wrote: >> member THURSDAY, FRIDAY, SATURDAY, SUNDAY; // don't force people >to >> write each entry on its own line; maybe even the "member" keyword is >too

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
th exists() and receive no notices. The things you could do with exists are simply impossible right now. It would not be a replacement for is_null, nor for isset(), but a way of writing a completely new type of code, which examined not a variable's value, but its state within the Engine.

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
tures can be used to write bad code, but it seems much easier to write bad code than good using this proposed function. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
Jefferson Gonzalez wrote on 18/09/2015 19:25: I also believe the rfc should include type hinting of enums as has been mentioned on this discussion. That would make enumerations more useful and the rfc more complete. It already mentions that: > Enums are strongly typed and can be used as param

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
thing as generic as exists(), and please don't edit the isset() documentation to recommend its usage in any but the most unusual cases. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
language, since I've been spending a lot of time talking down new features lately. :) Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
Lester Caine wrote on 18/09/2015 17:20: On 18/09/15 17:01, Rowan Collins wrote: Right, so stop talking about Notices. Ignoring Notices does not get you any closer to that goal. And stop lecturing me about Nulls. The is_null($foo) part of that is the part that already works fine. ONLY if $foo

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
Lester Caine wrote on 18/09/2015 16:55: On 18/09/15 16:35, Rowan Collins wrote: If what you want to write is "if ( ! exists($foo) || is_null($foo) ) { ... }" then that is exactly what "if ( isset($foo) )" will give you, without any notices whatsoever. NO what I want

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
ate, quite separate from null. If what you want to write is "if ( ! exists($foo) || is_null($foo) ) { ... }" then that is exactly what "if ( isset($foo) )" will give you, without any notices whatsoever. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Develo

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
Lester Caine wrote on 18/09/2015 15:39: On 18/09/15 15:06, Rowan Collins wrote: A PHP variable can have all sorts of states, because you can take advantage of loose typing: $date = new DateTime(); $date = null; $date = 'TODAY'; $date = -1; $date = M_PI; And isset() returns true for

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
g representation for debugging, or to do a dynamic Weekdays::getByName($_GET['day']), would be annoying. Regards, -- Rowan Collins [IMSoP]

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
variable can have all sorts of states, because you can take advantage of loose typing: $date = new DateTime(); $date = null; $date = 'TODAY'; $date = -1; $date = M_PI; etc Those are all readily distinguishable, and don't require any changes to the language for you to base your code around them. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
with exists(). No room for assumptions that lead you to not check the docs. I agree 100% with this. If we do add a new function, which I'm still not entirely convinced of the need for, we should be very explicit about what it does, and very careful in naming it. Regards, -- Rowan Co

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-18 Thread Rowan Collins
Lester Caine wrote on 18/09/2015 01:32: On 18/09/15 00:14, Rowan Collins wrote: I'm confused - do you mean that some rows in the result set from the database have columns "missing", rather than just set to NULL? That's not something I've ever come across before. Whi

[PHP-DEV] Re: Let's discuss enums!

2015-09-18 Thread Rowan Collins
Jefferson Gonzalez wrote on 18/09/2015 03:20: On 09/17/2015 08:05 PM, Rowan Collins wrote: I don't think serializing to a name is particularly more inefficient than serializing to an integer - depending on the internal implementation, of course. Or do you mean efficiency in terms of the l

Re: [PHP-DEV] Let's discuss enums!

2015-09-18 Thread Rowan Collins
erties of an object; so what is it about enums that makes having an integer accessible so important? I note that Java does supply an ordinal(), but the docs say you should basically never use it. Regards, -- Rowan Collins [IMSoP]

[PHP-DEV] Re: Let's discuss enums!

2015-09-17 Thread Rowan Collins
any difference, since most access would be of the form TypeName::ValueName. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Let's discuss enums!

2015-09-17 Thread Rowan Collins
s if not: enum RenewalAction{ Deny( 0 ), Approve( 1 ); public $ordinal; } enum Flags{ a (1 << 0), b( 1 << 1), c( 1 << 2), d( 1 << 3 ); public $value; } enum PimaryColours { RED, GREEN, BLUE } Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
) so it's use is not possible may be another 'fix'? Surely there are plenty of ways to use extract() without attempting to give meaning to missing variables. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Let's discuss enums!

2015-09-17 Thread Rowan Collins
URSDAY; foreach ( Weekdays::getMembers() as $day_name => $day ) { echo $day->dayNumber; if ( $day == $today ) { echo "Today!"; } else { echo $day_name; // equivalently: echo $day->getName(); } } // Do we need a static method to access a member by name, o

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
On 17/09/2015 20:51, Rowan Collins wrote: What would really be handy in a case like this is the ability to create your own null-like values, guaranteed to be distinct from all other values: type hidden extends \php\basetypes\terminal {} type default extends \php\basetypes\terminal

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
t have the notion of "does not exist" in tables or result sets - the result of a Left Join failing is the same type of Null as can be stored in a Nullable column. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
$checklist == deafult; // false isset($checklist); // true Maybe even: type missing extends \php\basetypes\null {} $foo = missing; isset($foo); // false is_null($foo); // not sure... Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
ons, so you couldn't use it until your code had a minimum version requirement of 7.1. A PECL extension *might* be able to backport it to older versions of PHP, but I doubt it would gain much adoption. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28?

2015-09-17 Thread Rowan Collins
Terry Cullen wrote on 17/09/2015 13:41: Here is an example where exists would be useful; You answered your own request: // I should have used property_exists() instead of isset().. wasn't expecting a null.. We already have that function, so that's alright then! :) As I've said several time

<    5   6   7   8   9   10   11   12   13   14   >