From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Kvcwa-0006Od-2S for garchives@archives.gentoo.org; Thu, 30 Oct 2008 19:12:32 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 37167E03E9; Thu, 30 Oct 2008 19:12:07 +0000 (UTC) Received: from yx-out-1718.google.com (yx-out-1718.google.com [74.125.44.157]) by pigeon.gentoo.org (Postfix) with ESMTP id 14FD7E03E9 for ; Thu, 30 Oct 2008 19:12:07 +0000 (UTC) Received: by yx-out-1718.google.com with SMTP id 4so357249yxp.46 for ; Thu, 30 Oct 2008 12:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=yYnLkTY9AnY+8jmj7ND32e/OjakyIgNtyJD4xd3cZl4=; b=dkzOsCD4+MEo6CfZsboctOe2eUbRwrr8uThyFvOy999W3c0PZbXQhEaKlv6iERYFrr UjQX9j4IzbD9SclwdmDVJkXyaG3hx2+jFXk4Y44K+vbJV2OvKwDJWpD429LWCODvzEW5 MEMSEv/SosOJtpds1SsaG7fVEcjW+I9vw74O4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=I0I0Pql2tB9xfHxlFKahKX5nM+JR22G326EkQQmMsYhNEidxhHzKO3FXyVCLigzID5 4nZAaYcP0qTHLBH969+5bzNC9w510zSaU0yA6Qrg89qKCvcz4NZmKLA0lfs+BLkDat+R T2d4hvQxguAHlu3J/kDtkBZGoDP8T+gnpTLHQ= Received: by 10.90.92.14 with SMTP id p14mr407793agb.52.1225393925262; Thu, 30 Oct 2008 12:12:05 -0700 (PDT) Received: by 10.90.81.1 with HTTP; Thu, 30 Oct 2008 12:12:05 -0700 (PDT) Message-ID: <38af3d670810301212v48d9be27tcab6cd45480eabf3@mail.gmail.com> Date: Thu, 30 Oct 2008 17:12:05 -0200 From: "Jorge Peixoto de Morais Neto" Sender: jorgepeixotomorais@gmail.com To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] package.keywords syntax? In-Reply-To: <79e3aefb0810300346m19d36196x4f3ec748f6a14be3@mail.gmail.com> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200810290041.39256.alan.mckinnon@gmail.com> <38af3d670810281555j43a2c0dfl990860eb9b85921b@mail.gmail.com> <200810290916.29649.alan.mckinnon@gmail.com> <38af3d670810291313p7937d68ei55d2b6ff9b9df6ad@mail.gmail.com> <79e3aefb0810300346m19d36196x4f3ec748f6a14be3@mail.gmail.com> X-Google-Sender-Auth: f55f74621d3e40c6 X-Archives-Salt: da0768c5-3362-412b-8f1b-19c3d048f763 X-Archives-Hash: ecdd298ed4a590f89dbf3112549eb3ea >> The real problem is when you type >> float real_number = 4e10; >> int integer = real_number; >> If your integer can only hold values up to 2^31 - 1 , the behavior of >> the above code is undefined. >> In a language like Python, everything either behaves as you intended, >> of throws an exception. >> This is why I say "In C, you must completely understand the behavior >> of every statement or function, and you *must* handle the possibility >> of errors". > > The line: > int integer = real_number; > will produce a warning. (or an error if you are smart enough to > compile with -Werror) It seems you did not get the point. To attribute a floating point number to an integer variable is perfectly valid, depending on the specific program. The compiler normally does not even warn about this, as this is perfectly valid (from my testing, the compiler only warns if you are using gcc 4.3, and specify -Wconversion, an option that is not included in -Wall and not even in -Wextra). So erase this *wrong idea* that attributing floating-point value to an integer variable is invalid or even just unwise. There is nothing generally wrong with it. The point is: in certain situations, the behavior is well-defined and unsurprising. What happens, though, if (for example) the value of the floating-point variable is too big for the int? In a forgiving language, you would either have a sensible behavior (such as the int receiving a INT_MAX value) or an error. In C the behavior is *undefined*. Got the point? In C, you *must* know what you are doing, and *must* handle the possibility of errors. If not, your program is not even garanteed to crash; it can, after an error, go on working (erratically), possibly damaging user data or yielding subtly wrong results without any warning. -- Software is like sex: it is better when it is free - Linus Torvalds