Article View: borland.public.jbuilder.java.language
Article #7938Re: Language puzzle
From: Dave Bird
Date: Tue, 01 May 2001 23:34
Date: Tue, 01 May 2001 23:34
43 lines
2304 bytes
2304 bytes
In article <3aef3645_1@dnews>, John McGrath [TeamB] <ng-
b@JPMcGrath.net> writes
>Here is an interesting little language question:
>
>Are the following two methods equivalent?
Good lord, you would surely be the man who knows.......?
What I THINK is.... functionally, they should do the same thing.
However, in code produced -- unless the compiler is so immensely
clever as to pick up that the second condition is exactly opposite
to the first -- they will be different. They will work EXACTLY
as you wrote.
>
> String booleanString( boolean b ) {
> String s;
> if ( b ) {
> s = "true";
> } else {
> s = "false";
> }
> return s;
> }
Approximately b, JFalse(L1), "true", =>#(s), Jmp(L2),
L1:, "false", =>#(s), L2: .
>
>And:
>
> String booleanString( boolean b ) {
> String s;
> if ( b ) s = "true";
> if ( !b ) s = "false";
> return s;
> }
Approximately b, JFalse(L1), "true", =>#(s); L1: ,
b, not, JFalse(L2), "false", =>#(s), L2: .
--
^-^-^-@@-^-;-^ http://www.xemu.demon.co.uk/
(..)__u news:alt.smoking.mooses
Technical Details
Message-ID:
<MhSBN1IGg076EwLj@xemu.demon.co.uk>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.icl.net!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!daveReferences:
<3aef3645_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,b65cd5c59c7b0e70 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-05-02 12:22:02 PST Path: arc1-ca.pugleaf.net!newsfeed.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out-sjo.usenetserver.com!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.icl.net!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!dave From: Dave Bird <dave@xemu.demon.co.uk> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Language puzzle Date: Wed, 2 May 2001 00:34:30 +0100 Organization: none Message-ID: <MhSBN1IGg076EwLj@xemu.demon.co.uk> References: <3aef3645_1@dnews> NNTP-Posting-Host: xemu.demon.co.uk X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209 X-Trace: news.demon.co.uk 988831152 nnrp-14:11331 NO-IDENT xemu.demon.co.uk:158.152.196.209 X-Complaints-To: abuse@demon.net MIME-Version: 1.0 X-Newsreader: Turnpike Integrated Version 5.00 U <dQumtnY$x4rJ2u5tL5fS$n2vuP> Lines: 44