Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92285 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6463 invoked from network); 14 Apr 2016 09:20:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 09:20:12 -0000 Authentication-Results: pb1.pair.com header.from=cornelius.howl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cornelius.howl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: cornelius.howl@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:33642] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/25-12455-BC06F075 for ; Thu, 14 Apr 2016 05:20:12 -0400 Received: by mail-oi0-f51.google.com with SMTP id w85so87941731oiw.0 for ; Thu, 14 Apr 2016 02:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=2vorGFwFmfpBV2vDf4Mz2dq4/YdCYHdruND5HJAa8ZY=; b=fBJERIgkxViB3ucEnzlWoQKInTAD5IaajDFxztcAm/oJQDeFtsPKnEdQVvxEjilwCP xEcXW6oZ4E9O//dv1+dlm7z+f98Q06zk/67J4a1Kyh2DmK+/2aCkGsuVm0I4+ihmkFzO f77gZw2nAPFG39IKyeS6krcJglpRmXKT5KnuuzWiZUIdFTKWY6ZYxtuDGjnf9WZ7qiB3 QxnxLy0e5ez/WF7HQfQJQDTwmcDt1POm2hQEGO6nKurPWSgRimENYo5D32CXn1VvVjiU slGZo9wgyETp4KS1xgt0uiNfgeSz47KZ8mMS9GOHbxdJGKAwcQxPjYNe2o4i7zij1mp/ m2fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=2vorGFwFmfpBV2vDf4Mz2dq4/YdCYHdruND5HJAa8ZY=; b=HidIkSnaAAvLIoxiH+Q0bJ5UDVl5yLu5XqCBhuzXeoH/RLg1GKp4ZbJszM26IFcU2O lJsDU7zp5vQMiZCkXPi6Kvglw4dKqk/ZoXeAajYynH/00G0weaVio82QOrzGiF5fPndg t4nkVU+r4Ieyk3EA+lp4wJeogHcaQR8l6xVuGFOEM8RXqboDeyncTLFSD+a4gyzMrO/f yhfui/8gWskKwxx9tjj6Gng5+LhV5k5J8NTq9LEQy010rArYrlKl2zwh29SfzigPrbBb HRJurwXLUVqO49PlUPXxJ1be3UeBj41lOgwjkdwyZoU0LVZl6oug2OxWupf1i/Eo6xjP y1bQ== X-Gm-Message-State: AOPr4FW4IUNVtIlZv8W1cAVa4neoRpr6Tz2mRkd6viRBtyF33OmhbRqgjYiDZhludw0RVWrYTFVZd01ENZUoVQ== MIME-Version: 1.0 X-Received: by 10.202.54.212 with SMTP id d203mr6841037oia.23.1460625608637; Thu, 14 Apr 2016 02:20:08 -0700 (PDT) Received: by 10.157.7.194 with HTTP; Thu, 14 Apr 2016 02:20:08 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Apr 2016 17:20:08 +0800 Message-ID: To: Derick Rethans Cc: Levi Morrison , internals Content-Type: multipart/alternative; boundary=001a113cd3fe8d83c505306e6626 Subject: Re: [PHP-DEV] [RFC] Union Types From: cornelius.howl@gmail.com (Lin Yo-An) --001a113cd3fe8d83c505306e6626 Content-Type: text/plain; charset=UTF-8 On Thu, Apr 14, 2016 at 5:12 PM, Derick Rethans wrote: > I think what I am missing in the RFC is behaviour with scalar (weak) > typehints, and which type the variable in a class would be converted to. > Take for example: > > function foo(int|bool $var) { echo get_type( $var ), "\n"; } > > foo(5); I guess int(5) > foo(false); I guess bool(false) > foo(0.5); It could be either int(1) or bool(true) > > And what if the hint would be "bool|int" ? > I think type conversion shouldn't be done internally, implicitly. Implicit conversion leads more confusion in the language. when you pass variables, you have to remember these conversion rules. type conversion should be done in the caller, that's why typed language like C or C++ ask you to convert the type manually before you pass the variable into a function. -- Best Regards, Yo-An Lin --001a113cd3fe8d83c505306e6626--