MESSAGE
DATE | 2016-04-26 |
FROM | Christopher League
|
SUBJECT | Re: [Hangout-NYLXS] error: unclosed character literal
|
From hangout-bounces-at-nylxs.com Wed Apr 27 00:08:02 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 87403163D45; Wed, 27 Apr 2016 00:08:01 -0400 (EDT) X-Original-To: hangout-at-nylxs.com Delivered-To: hangout-at-nylxs.com Received: by mrbrklyn.com (Postfix, from userid 1000) id 03442162A0A; Wed, 27 Apr 2016 00:07:56 -0400 (EDT) Resent-From: Ruben Safir Resent-Date: Wed, 27 Apr 2016 00:07:56 -0400 Resent-Message-ID: <20160427040756.GD1115-at-www.mrbrklyn.com> Resent-To: hangout-at-nylxs.com X-Original-To: ruben-at-mrbrklyn.com Delivered-To: ruben-at-mrbrklyn.com Received: from B-EXH-EDGE1.liunet.edu (b-edge1.smtp.liu.edu [148.4.248.206]) by mrbrklyn.com (Postfix) with ESMTP id F277C161224 for ; Tue, 26 Apr 2016 09:48:51 -0400 (EDT) Received: from B-EXH-3.liunet.edu (148.4.250.212) by B-EXH-EDGE1.liunet.edu (148.4.248.206) with Microsoft SMTP Server (TLS) id 14.3.210.2; Tue, 26 Apr 2016 09:48:44 -0400 Received: from localhost (96.250.202.133) by B-EXH-3.liunet.edu (148.4.250.212) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Apr 2016 09:48:49 -0400 From: Christopher League To: Ruben Safir , Hangout In-Reply-To: <571F0BCB.2050007-at-mrbrklyn.com> References: <571F0BCB.2050007-at-mrbrklyn.com> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu) Date: Tue, 26 Apr 2016 09:48:46 -0400 Message-ID: <87bn4wqy4h.fsf-at-lydrik.home.lan> MIME-Version: 1.0 X-Originating-IP: [96.250.202.133] X-ClientProxiedBy: U-EXH-CAS.liunet.edu (148.4.184.26) To B-EXH-3.liunet.edu (148.4.250.212) X-Content-Filtered-By: Mailman/MimeDel 2.1.17 Subject: Re: [Hangout-NYLXS] error: unclosed character literal X-BeenThere: hangout-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list Reply-To: NYLXS Discussions List List-Id: NYLXS Discussions List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============1821118764==" Errors-To: hangout-bounces-at-nylxs.com Sender: "hangout"
--===============1821118764== Content-Type: multipart/signed; boundary="===-=-="; micalg=pgp-sha256; protocol="application/pgp-signature"
--===-=-= Content-Type: multipart/alternative; boundary="==-=-="
--==-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Yeah, I think this is because the single quote only works for a single character in C/Java so `'>=3D'` is not allowed. Assuming the type of `op` is `String`, then you can do `op =3D=3D ">=3D"` or probably even better, `op.equals(">=3D")`.
Comparing strings in Java with `=3D=3D` is not always reliable, because it uses object (pointer) equality. If they are two different string objects, they'll register as not-equal, even if they have the same characters. Therefore, `op.equals(">=3D")` is recommended, because it actually looks at the characters. (Just like in C, you use `strcmp` instead of `=3D=3D` for the same reason.)
Another possibility that Java supports and C doesn't is that you can use a string in a switch:
switch(op) { case ">=3D": case ">": // etc. break }
and it compiles that to use `op.equals()` behind the scenes.
CL
Ruben Safir writes:
> TypeCheckingVisitor.java:61: error: unclosed character literal > if(op =3D=3D '>' || op =3D=3D '<' || op =3D=3D '<=3D' ||= op =3D=3D '>=3D' ){ > > > The editor also indicates a parsing problem in the Java but I am at a los= s. > > '<' seems to work > > > This is the code snippet > > //Comparison Operators > =C2=A6if(op =3D=3D '>' || op =3D=3D '<' || op =3D=3D '<=3D' || op = =3D=3D '>=3D' ){ > =C2=A6if( (leftType =3D=3D Type.INT && rightType =3D=3D Type.INT= ) || (leftType=3D=3D Type.FLOAT || rightType=3D=3D Type.FLOAT)|| (leftType = =3D=3D Type.INT && rightType =3D=3D Type.FLOAT)|| (leftType =3D=3D Type.FLO= AT && rightType =3D=3D Type.INT ) ){ > =C2=A6return trace(ctx, Type.BOOL); > =C2=A6} > =C2=A6 =C2=A6 =C2=A6return typeMismatch(ctx, leftType, rightType); > > =C2=A6}=20=20 > > --=20 > So many immigrant groups have swept through our town > that Brooklyn, like Atlantis, reaches mythological > proportions in the mind of the world - RI Safir 1998 > http://www.mrbrklyn.com=20 > > DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 > http://www.nylxs.com - Leadership Development in Free Software > http://www2.mrbrklyn.com/resources - Unpublished Archive > http://www.coinhangout.com - coins! > http://www.brooklyn-living.com > > Being so tracked is for FARM ANIMALS and and extermination camps, > but incompatible with living as a free human being. -RI Safir 2013
--==-=-= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"
Yeah, I think this is because the single quote only works for a single character in C/Java so '>=' is not allowed. Assuming the type of op is String, then you can do op == ">=" or probably even better, op.equals(">=").
Comparing strings in Java with == is not always reliable, because it uses object (pointer) equality. If they are two different string objects, they'll register as not-equal, even if they have the same characters. Therefore, op.equals(">=") is recommended, because it actually looks at the characters. (Just like in C, you use strcmp instead of == for the same reason.)
Another possibility that Java supports and C doesn't is that you can use a string in a switch: switch(op) { case ">=": case ">": // etc. break }
and it compiles that to use op.equals() behind the scenes.
CL
Ruben Safir [1]ruben-at-mrbrklyn.com writes:
TypeCheckingVisitor.java:61: error: unclosed character literal if(op == `>' || op == `<' || op == `<=' || op == `>=' ){
The editor also indicates a parsing problem in the Java but I am at a loss.
`<' seems to work
This is the code snippet
//Comparison Operators ?if(op == `>' || op == `<' || op == `<=' || op == `>=' ){ ?if( (leftType == Type.INT && rightType == Type.INT) || (leftType== Type.FLOAT || rightType== Type.FLOAT)|| (leftType == Type.INT && rightType == Type.FLOAT)|| (leftType == Type.FLOAT && rightType == Type.INT ) ){ ?return trace(ctx, Type.BOOL); ?} ? ? ?return typeMismatch(ctx, leftType, rightType); ?}
- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
References
1. mailto:ruben-at-mrbrklyn.com
--==-=-=--
--===-=-= Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQEcBAEBCAAGBQJXH3G+AAoJEGuLsz1PMbCLtZQH/iQElhic6tQ+LjVcq/BSMQLT zVMDG/ddqhzZC2rx6m3pYv9FQ2wAEKW2q5nH0OoVqXRdo9dCIS+vr37FtIk9f+Ys dGRJ6K0bDNvVAUiVB5poP3Rc/3ho4nJumP1+NUA+keKW5sj33jaUCxOdb4pN4cxk 6xG0E/xFtAQROehvrKkz+vQwlJCmqx6DSwfr6gwVdo0baEqK6mBThiyCMID+Zkez ZMxMTV8pF/cqwoK1Q+eEx1Afjfrol8QLUpoY05Qnim0e3Q320YEGngJcLjkgURTP bKRp8xCdH21+bEU9RdI6yAjlcqxa72V4isBqRAAPtp0/iYtuzgj+L1HMS3cU57E= =huOO -----END PGP SIGNATURE----- --===-=-=--
--===============1821118764== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ hangout mailing list hangout-at-nylxs.com http://www.nylxs.com/ --===============1821118764==--
--===============1821118764== Content-Type: multipart/signed; boundary="===-=-="; micalg=pgp-sha256; protocol="application/pgp-signature"
--===-=-= Content-Type: multipart/alternative; boundary="==-=-="
--==-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Yeah, I think this is because the single quote only works for a single character in C/Java so `'>=3D'` is not allowed. Assuming the type of `op` is `String`, then you can do `op =3D=3D ">=3D"` or probably even better, `op.equals(">=3D")`.
Comparing strings in Java with `=3D=3D` is not always reliable, because it uses object (pointer) equality. If they are two different string objects, they'll register as not-equal, even if they have the same characters. Therefore, `op.equals(">=3D")` is recommended, because it actually looks at the characters. (Just like in C, you use `strcmp` instead of `=3D=3D` for the same reason.)
Another possibility that Java supports and C doesn't is that you can use a string in a switch:
switch(op) { case ">=3D": case ">": // etc. break }
and it compiles that to use `op.equals()` behind the scenes.
CL
Ruben Safir writes:
> TypeCheckingVisitor.java:61: error: unclosed character literal > if(op =3D=3D '>' || op =3D=3D '<' || op =3D=3D '<=3D' ||= op =3D=3D '>=3D' ){ > > > The editor also indicates a parsing problem in the Java but I am at a los= s. > > '<' seems to work > > > This is the code snippet > > //Comparison Operators > =C2=A6if(op =3D=3D '>' || op =3D=3D '<' || op =3D=3D '<=3D' || op = =3D=3D '>=3D' ){ > =C2=A6if( (leftType =3D=3D Type.INT && rightType =3D=3D Type.INT= ) || (leftType=3D=3D Type.FLOAT || rightType=3D=3D Type.FLOAT)|| (leftType = =3D=3D Type.INT && rightType =3D=3D Type.FLOAT)|| (leftType =3D=3D Type.FLO= AT && rightType =3D=3D Type.INT ) ){ > =C2=A6return trace(ctx, Type.BOOL); > =C2=A6} > =C2=A6 =C2=A6 =C2=A6return typeMismatch(ctx, leftType, rightType); > > =C2=A6}=20=20 > > --=20 > So many immigrant groups have swept through our town > that Brooklyn, like Atlantis, reaches mythological > proportions in the mind of the world - RI Safir 1998 > http://www.mrbrklyn.com=20 > > DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 > http://www.nylxs.com - Leadership Development in Free Software > http://www2.mrbrklyn.com/resources - Unpublished Archive > http://www.coinhangout.com - coins! > http://www.brooklyn-living.com > > Being so tracked is for FARM ANIMALS and and extermination camps, > but incompatible with living as a free human being. -RI Safir 2013
--==-=-= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"
Yeah, I think this is because the single quote only works for a single character in C/Java so '>=' is not allowed. Assuming the type of op is String, then you can do op == ">=" or probably even better, op.equals(">=").
Comparing strings in Java with == is not always reliable, because it uses object (pointer) equality. If they are two different string objects, they'll register as not-equal, even if they have the same characters. Therefore, op.equals(">=") is recommended, because it actually looks at the characters. (Just like in C, you use strcmp instead of == for the same reason.)
Another possibility that Java supports and C doesn't is that you can use a string in a switch: switch(op) { case ">=": case ">": // etc. break }
and it compiles that to use op.equals() behind the scenes.
CL
Ruben Safir [1]ruben-at-mrbrklyn.com writes:
TypeCheckingVisitor.java:61: error: unclosed character literal if(op == `>' || op == `<' || op == `<=' || op == `>=' ){
The editor also indicates a parsing problem in the Java but I am at a loss.
`<' seems to work
This is the code snippet
//Comparison Operators ?if(op == `>' || op == `<' || op == `<=' || op == `>=' ){ ?if( (leftType == Type.INT && rightType == Type.INT) || (leftType== Type.FLOAT || rightType== Type.FLOAT)|| (leftType == Type.INT && rightType == Type.FLOAT)|| (leftType == Type.FLOAT && rightType == Type.INT ) ){ ?return trace(ctx, Type.BOOL); ?} ? ? ?return typeMismatch(ctx, leftType, rightType); ?}
- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
References
1. mailto:ruben-at-mrbrklyn.com
--==-=-=--
--===-=-= Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2
iQEcBAEBCAAGBQJXH3G+AAoJEGuLsz1PMbCLtZQH/iQElhic6tQ+LjVcq/BSMQLT zVMDG/ddqhzZC2rx6m3pYv9FQ2wAEKW2q5nH0OoVqXRdo9dCIS+vr37FtIk9f+Ys dGRJ6K0bDNvVAUiVB5poP3Rc/3ho4nJumP1+NUA+keKW5sj33jaUCxOdb4pN4cxk 6xG0E/xFtAQROehvrKkz+vQwlJCmqx6DSwfr6gwVdo0baEqK6mBThiyCMID+Zkez ZMxMTV8pF/cqwoK1Q+eEx1Afjfrol8QLUpoY05Qnim0e3Q320YEGngJcLjkgURTP bKRp8xCdH21+bEU9RdI6yAjlcqxa72V4isBqRAAPtp0/iYtuzgj+L1HMS3cU57E= =huOO -----END PGP SIGNATURE----- --===-=-=--
--===============1821118764== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ hangout mailing list hangout-at-nylxs.com http://www.nylxs.com/ --===============1821118764==--
|
|