From cab760a1b7912548daf2fa033f11b4ea939a86f3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Jan 2015 15:08:36 -0500 Subject: this was sitting there --- web/lukeshu.ath.cx/1/wordpress/2011/01/index.chtml | 205 +++++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/01/index.html | 202 +++++++++++++ .../wordpress/2011/01/java-has-issues/index.chtml | 269 +++++++++++++++++ .../1/wordpress/2011/01/java-has-issues/index.html | 266 +++++++++++++++++ .../wordpress/2011/01/pointers-in-java/index.chtml | 328 +++++++++++++++++++++ .../wordpress/2011/01/pointers-in-java/index.html | 325 ++++++++++++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/02/index.chtml | 176 +++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/02/index.html | 173 +++++++++++ .../index.chtml | 225 ++++++++++++++ .../index.html | 222 ++++++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/05/index.chtml | 176 +++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/05/index.html | 173 +++++++++++ .../wordpress/2011/05/why-sed-i-exists/index.chtml | 198 +++++++++++++ .../wordpress/2011/05/why-sed-i-exists/index.html | 195 ++++++++++++ .../index.chtml | 231 +++++++++++++++ .../index.html | 228 ++++++++++++++ .../index.chtml | 202 +++++++++++++ .../index.html | 199 +++++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/08/index.chtml | 205 +++++++++++++ web/lukeshu.ath.cx/1/wordpress/2011/08/index.html | 202 +++++++++++++ 20 files changed, 4400 insertions(+) create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/02/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/02/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/05/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/05/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.html create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/index.chtml create mode 100644 web/lukeshu.ath.cx/1/wordpress/2011/08/index.html (limited to 'web/lukeshu.ath.cx/1/wordpress/2011') diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/01/index.chtml new file mode 100644 index 0000000..d5655a1 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/index.chtml @@ -0,0 +1,205 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/01/. It is a snapshot of the page as it appeared on Dec 6, 2011 12:11:24 GMT. The current page could have changed in the meantime. Learn more

Text-only version
+
 
+ + + + + January | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: January 2011

+ + +
+ +

Pointers in Java

+ + + + +
+

This was originally posted to Facebook by me at 2010-08-02 23:20. Note: For purposes of anyone interested in this, pointers in Java are more commonly referred to as references, because everything in Java must have it’s own name (method vs. … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + 2 Comments + +
+ +
+ +
+ +

Java has issues

+ + + + +
+

This was originally posted to Facebook by me at 2010-09-02 23:19. It was edited by me there 2010-07-03. Java is an alright language. There are a lot of things it does right, but there are a few things it doesn’t. … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/01/index.html new file mode 100644 index 0000000..c0503d3 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/index.html @@ -0,0 +1,202 @@ + + + + + January | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: January 2011

+ + +
+ +

Pointers in Java

+ + + + +
+

This was originally posted to Facebook by me at 2010-08-02 23:20. Note: For purposes of anyone interested in this, pointers in Java are more commonly referred to as references, because everything in Java must have it’s own name (method vs. … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + 2 Comments + +
+ +
+ +
+ +

Java has issues

+ + + + +
+

This was originally posted to Facebook by me at 2010-09-02 23:19. It was edited by me there 2010-07-03. Java is an alright language. There are a lot of things it does right, but there are a few things it doesn’t. … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.chtml new file mode 100644 index 0000000..afc5885 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.chtml @@ -0,0 +1,269 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/. It is a snapshot of the page as it appeared on Dec 7, 2011 21:53:20 GMT. The current page could have changed in the meantime. Learn more

Text-only version
+
 
+ + + + + Java has issues | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Java has issues

+ +
+

This was originally posted to Facebook by me at 2010-09-02 23:19. It was edited by me there 2010-07-03.

+

Java is an alright language. There are a lot of things it does right, but there
+are a few things it doesn’t.

+
    +
  1. Distinction between classes and packages. I should be able to create
    + sub-classes the same way as I add classes to a package; a package should
    + just be an empty class.
  2. +
  3. Too many primitives. I should be able to (re-)construct more of the
    + language.
  4. +
  5. No preprocessor/inlines. OO isn’t an excuse for this, make me do it at the
    + class level (or rather, source file, not supporting `#include’ is fine). I
    + should at least be able to add `#define int8=byte’ like in C. This
    + wouldn’t be as much of an issue if all these things weren’t primitives; I
    + could just do “public class int8 extends byte”. (yes, I could extend the
    + `Byte’ class, but it wouldn’t come with all the syntactic sugar primitives
    + get.)
  6. +
  7. Numbers: names. Yes the names used are long-standing convention in CS.
    + These include some of the worst short-sighted mistakes in all of
    + hackerdom… because they stuck. Yet, most reasonable languages can still
    + support them, and sane equivalents.

    +
      +
    • byte -> int8
    • +
    • short -> int16
    • +
    • int -> int32
    • +
    • long -> int64
    • +
    • float -> float32
    • +
    • double -> float64
    • +
    +

    This would easily be fixed if they weren’t all primitives (point 2), or if
    + I had a preprocessor (point 3).

  8. +
  9. Numbers: unsigned. How about unsigned integers (uint16)? This would be
    + easy to implement, if everything weren’t a damn primitive.
  10. +
  11. Give me an actual `struct’, like in C. I’m not asking for full manual
    + memory management, just the ability to organize a chunk of it; you can
    + still manage it for me. It would make serialization hellofalot
    + easier.
  12. +
  13. It’s inconsistent about whether it uses the system encoding or it’s
    + internal encoding. The String object just became worthless to anyone
    + wanting to do any amount of I18N.
  14. +
  15. It’s internal encoding is junk. It maps UTF-16 symbols onto the `char’
    + primitive, which is 16 bits.

    +
      +
    1. UTF-16 is junk, use UTF-8
    2. +
    3. With any UTF encoding you must allow for a dynamic bit-length, for
      + UTF-16 it’s 16-32 bits, UTF-8 is 8-32 bits
    4. +
    +

    I understand how/why it arrived at the solution it uses; at the time Java
    + was designed, it was using UCS-2, which is a 16-bit encoding, and was
    + superseded by UTF-16 in 1996 with Unicode 2.0. However, this is one of
    + those things where you specify a new JVM version, and switch to UTF-8. You
    + can even leave a legacy mode in the JVM that still uses UCS-2.

  16. +
  17. Octal prefix: `0′ is used as the prefix to specify an octal literal. Any
    + third-grader can tell you why using a 0 as a prefix to a number is a bad
    + idea; the number might just have padded zeros. Let’s look at the prefix
    + used for hexadecimal: `0x’. This is great:

    +
      +
    1. It starts with a numeric character, which means that it must be a
      + literal. If it started with an alphabetic character, it might be a
      + variable name.
    2. +
    3. The second character is a alphabetic character that is not used in
      + any number system that is used in computer science. This allows it
      + to serve a a unique identifier.
    4. +
    +

    Given these reasons, let’s think of a new prefix for octal… how about
    + `0o’. That took literally less than 10 seconds for me to realize why `0′
    + sucked, and to think of a better one.*

  18. +
+

All-in-all, its still better than C++

+

* although, writing this gave me an even
+better idea, but it would break `0x<value>’ for hex, which is incredibly
+common among many languages:
+`<base-in-decimal>x<value>’
+so octal would be `8x<value>’
+and hex would be `16x<value>’
+It would be incredibly understandable, and, depending on implementation allow
+simple arbitrary-base literals.

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.html new file mode 100644 index 0000000..99e751c --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/java-has-issues/index.html @@ -0,0 +1,266 @@ + + + + + Java has issues | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Java has issues

+ +
+

This was originally posted to Facebook by me at 2010-09-02 23:19. It was edited by me there 2010-07-03.

+

Java is an alright language. There are a lot of things it does right, but there
+are a few things it doesn’t.

+
    +
  1. Distinction between classes and packages. I should be able to create
    + sub-classes the same way as I add classes to a package; a package should
    + just be an empty class.
  2. +
  3. Too many primitives. I should be able to (re-)construct more of the
    + language.
  4. +
  5. No preprocessor/inlines. OO isn’t an excuse for this, make me do it at the
    + class level (or rather, source file, not supporting `#include’ is fine). I
    + should at least be able to add `#define int8=byte’ like in C. This
    + wouldn’t be as much of an issue if all these things weren’t primitives; I
    + could just do “public class int8 extends byte”. (yes, I could extend the
    + `Byte’ class, but it wouldn’t come with all the syntactic sugar primitives
    + get.)
  6. +
  7. Numbers: names. Yes the names used are long-standing convention in CS.
    + These include some of the worst short-sighted mistakes in all of
    + hackerdom… because they stuck. Yet, most reasonable languages can still
    + support them, and sane equivalents.

    +
      +
    • byte -> int8
    • +
    • short -> int16
    • +
    • int -> int32
    • +
    • long -> int64
    • +
    • float -> float32
    • +
    • double -> float64
    • +
    +

    This would easily be fixed if they weren’t all primitives (point 2), or if
    + I had a preprocessor (point 3).

  8. +
  9. Numbers: unsigned. How about unsigned integers (uint16)? This would be
    + easy to implement, if everything weren’t a damn primitive.
  10. +
  11. Give me an actual `struct’, like in C. I’m not asking for full manual
    + memory management, just the ability to organize a chunk of it; you can
    + still manage it for me. It would make serialization hellofalot
    + easier.
  12. +
  13. It’s inconsistent about whether it uses the system encoding or it’s
    + internal encoding. The String object just became worthless to anyone
    + wanting to do any amount of I18N.
  14. +
  15. It’s internal encoding is junk. It maps UTF-16 symbols onto the `char’
    + primitive, which is 16 bits.

    +
      +
    1. UTF-16 is junk, use UTF-8
    2. +
    3. With any UTF encoding you must allow for a dynamic bit-length, for
      + UTF-16 it’s 16-32 bits, UTF-8 is 8-32 bits
    4. +
    +

    I understand how/why it arrived at the solution it uses; at the time Java
    + was designed, it was using UCS-2, which is a 16-bit encoding, and was
    + superseded by UTF-16 in 1996 with Unicode 2.0. However, this is one of
    + those things where you specify a new JVM version, and switch to UTF-8. You
    + can even leave a legacy mode in the JVM that still uses UCS-2.

  16. +
  17. Octal prefix: `0′ is used as the prefix to specify an octal literal. Any
    + third-grader can tell you why using a 0 as a prefix to a number is a bad
    + idea; the number might just have padded zeros. Let’s look at the prefix
    + used for hexadecimal: `0x’. This is great:

    +
      +
    1. It starts with a numeric character, which means that it must be a
      + literal. If it started with an alphabetic character, it might be a
      + variable name.
    2. +
    3. The second character is a alphabetic character that is not used in
      + any number system that is used in computer science. This allows it
      + to serve a a unique identifier.
    4. +
    +

    Given these reasons, let’s think of a new prefix for octal… how about
    + `0o’. That took literally less than 10 seconds for me to realize why `0′
    + sucked, and to think of a better one.*

  18. +
+

All-in-all, its still better than C++

+

* although, writing this gave me an even
+better idea, but it would break `0x<value>’ for hex, which is incredibly
+common among many languages:
+`<base-in-decimal>x<value>’
+so octal would be `8x<value>’
+and hex would be `16x<value>’
+It would be incredibly understandable, and, depending on implementation allow
+simple arbitrary-base literals.

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.chtml new file mode 100644 index 0000000..860edd2 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.chtml @@ -0,0 +1,328 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/. It is a snapshot of the page as it appeared on Dec 15, 2011 09:12:44 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + Pointers in Java | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Pointers in Java

+ +
+

This was originally posted to Facebook by me at 2010-08-02 23:20.

+

Note: For purposes of anyone interested in this, pointers in Java are more commonly referred to as references, because everything in Java must have it’s own name (method vs. function). This makes operating the Google DuckDuckGo machine easier. I wish I had known that when I wrote this.

+
+In Java there are a few `primitive' datatypes, the rest of the datatypes are
+implemented as classes.  They are:
+
+byte
+short
+int
+long
+float
+double
+char
+<pointer>
+
+Normally, when declaring a primitive, you write the type of the primitive as
+the variable type.  However, the reason I wrote pointer in brackets is that you
+DON'T write pointer when declaring a variable storing a pointer.
+
+For example, when I write
+java.util.Stack stack = new java.util.Stack();
+The variable stack does NOT store an object. It stores a /pointer/ to an object.
+A pointer stores the memory address where a object is stored.
+
+ALL VARIABLES STORE PRIMITIVES, IT IS IMPOSSIBLE TO STORE AN OBJECT.
+For this reason, it is possible for the JVM to manage memory for you; it keeps
+track of the pointers, and once there are no more pointers pointing to a
+particular object, it can be deleted.
+
+Why does this matter?  Well, consider that `String' is a class
+(`java.lang.String'), not a primitive.  Consider the following code:
+
+String str1 = "foo";
+String str2 = "foo";
+return (str1 == str2);
+
+If String were a primitive, it would return true; but it returns false.
+Strings are a little complex because they contain syntactic sugar.  Let's do
+the same example with an integer instead:
+
+Integer int1 = new Integer(5);
+Integer int2 = new Integer(5);
+return (int1 == int2);
+
+The `java.lang.Integer' class is a class wrapper around the `int' primitive.
+The `new' operator creates a class, and returns a pointer to it.  The source
+code to the java.lang.Integer class contains the:
+    private int value;
+
+    public Integer(int val) {
+        value = val;
+    }
+
+So, the above example generates to objects belonging to the java.lang.Integer
+class.  Even though the .value's of the two objects are the same, they are
+separate objects.  Therefore, int1 and int2 store two separate memory locations.
+These two locations in the memory store the same data, but it is stored at both
+locations.
+
+The `==' operator takes two primitives, and compares their direct values.
+Since int1 and int2 store two different memory locations, `(int1 == int2)'
+evaluates to false.
+
+

Note: as pointed out by Ari Consul, everything following is false. The JVM does not copy the objects, it returns the pointer directly (no magic, as I’d suggested). The JVM will free() the object when there are no more pointers to it, via basic reference-counting

+
+About copying objects:  when returning a private pointer, the JVM makes a copy
+of the object that the pointer points to, and returns a pointer to the new
+object, NOT the original pointer.
+
+For example if I declare the method:
+
+public static Integer getInt() {
+    Integer val = new Integer(5);
+    return val;
+}
+
+It does NOT actually return `val'; it returns a new pointer to a copy of the
+object that val pointed to.
+
+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+ +

2 Responses to Pointers in Java

+ +
    + +
  1. +
    +
    + + Ari Consul says: +
    + + +
    +

    Nice blog, keep discovering and posting!

    +

    The last part is incorrect. getInt() (a bad name BTW: newIntFive() or intFiveFactory() would be a better description) creates a new Integer object, a reference to the Integer object and assigns the object reference to val. getInt() then returns a copy of the object reference. There is no implicit object copying here.

    +

    Some relevant URLs:
    +http://oopweb.com/Java/Documents/ThinkingInJava/Volume/TIJ319.htm#Index2146
    +http://javadude.com/articles/passbyvalue.htm
    +http://java.sun.com/docs/books/jls/third_edition/html/statements.html#6767

    +
    +
    + Reply +
    +
    + +
      + +
    • +
      +
      + + lts says: +
      + + +
      +

      Thank you!

      +

      I know that now, but at the time I’d written it, I had been using Java for less than 6 monthsa very short time. My previous statement was based on a flawed understanding of how Java did garbage collection.

      +

      Of course, the code example wasn’t meant to do anything, just be an example of allocing an object and returning a pointer.

      +

      BTW, if you don’t mind me asking, what lead you here?

      +
      +
      + Reply +
      +
      + +
    • +
    +
  2. + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.html new file mode 100644 index 0000000..6e78d68 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/01/pointers-in-java/index.html @@ -0,0 +1,325 @@ + + + + + Pointers in Java | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Pointers in Java

+ +
+

This was originally posted to Facebook by me at 2010-08-02 23:20.

+

Note: For purposes of anyone interested in this, pointers in Java are more commonly referred to as references, because everything in Java must have it’s own name (method vs. function). This makes operating the Google DuckDuckGo machine easier. I wish I had known that when I wrote this.

+
+In Java there are a few `primitive' datatypes, the rest of the datatypes are
+implemented as classes.  They are:
+
+byte
+short
+int
+long
+float
+double
+char
+<pointer>
+
+Normally, when declaring a primitive, you write the type of the primitive as
+the variable type.  However, the reason I wrote pointer in brackets is that you
+DON'T write pointer when declaring a variable storing a pointer.
+
+For example, when I write
+java.util.Stack stack = new java.util.Stack();
+The variable stack does NOT store an object. It stores a /pointer/ to an object.
+A pointer stores the memory address where a object is stored.
+
+ALL VARIABLES STORE PRIMITIVES, IT IS IMPOSSIBLE TO STORE AN OBJECT.
+For this reason, it is possible for the JVM to manage memory for you; it keeps
+track of the pointers, and once there are no more pointers pointing to a
+particular object, it can be deleted.
+
+Why does this matter?  Well, consider that `String' is a class
+(`java.lang.String'), not a primitive.  Consider the following code:
+
+String str1 = "foo";
+String str2 = "foo";
+return (str1 == str2);
+
+If String were a primitive, it would return true; but it returns false.
+Strings are a little complex because they contain syntactic sugar.  Let's do
+the same example with an integer instead:
+
+Integer int1 = new Integer(5);
+Integer int2 = new Integer(5);
+return (int1 == int2);
+
+The `java.lang.Integer' class is a class wrapper around the `int' primitive.
+The `new' operator creates a class, and returns a pointer to it.  The source
+code to the java.lang.Integer class contains the:
+    private int value;
+
+    public Integer(int val) {
+        value = val;
+    }
+
+So, the above example generates to objects belonging to the java.lang.Integer
+class.  Even though the .value's of the two objects are the same, they are
+separate objects.  Therefore, int1 and int2 store two separate memory locations.
+These two locations in the memory store the same data, but it is stored at both
+locations.
+
+The `==' operator takes two primitives, and compares their direct values.
+Since int1 and int2 store two different memory locations, `(int1 == int2)'
+evaluates to false.
+
+

Note: as pointed out by Ari Consul, everything following is false. The JVM does not copy the objects, it returns the pointer directly (no magic, as I’d suggested). The JVM will free() the object when there are no more pointers to it, via basic reference-counting

+
+About copying objects:  when returning a private pointer, the JVM makes a copy
+of the object that the pointer points to, and returns a pointer to the new
+object, NOT the original pointer.
+
+For example if I declare the method:
+
+public static Integer getInt() {
+    Integer val = new Integer(5);
+    return val;
+}
+
+It does NOT actually return `val'; it returns a new pointer to a copy of the
+object that val pointed to.
+
+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+ +

2 Responses to Pointers in Java

+ +
    + +
  1. +
    +
    + + Ari Consul says: +
    + + +
    +

    Nice blog, keep discovering and posting!

    +

    The last part is incorrect. getInt() (a bad name BTW: newIntFive() or intFiveFactory() would be a better description) creates a new Integer object, a reference to the Integer object and assigns the object reference to val. getInt() then returns a copy of the object reference. There is no implicit object copying here.

    +

    Some relevant URLs:
    +http://oopweb.com/Java/Documents/ThinkingInJava/Volume/TIJ319.htm#Index2146
    +http://javadude.com/articles/passbyvalue.htm
    +http://java.sun.com/docs/books/jls/third_edition/html/statements.html#6767

    +
    +
    + Reply +
    +
    + +
      + +
    • +
      +
      + + lts says: +
      + + +
      +

      Thank you!

      +

      I know that now, but at the time I’d written it, I had been using Java for less than 6 monthsa very short time. My previous statement was based on a flawed understanding of how Java did garbage collection.

      +

      Of course, the code example wasn’t meant to do anything, just be an example of allocing an object and returning a pointer.

      +

      BTW, if you don’t mind me asking, what lead you here?

      +
      +
      + Reply +
      +
      + +
    • +
    +
  2. + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/02/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/02/index.chtml new file mode 100644 index 0000000..5c27bf8 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/02/index.chtml @@ -0,0 +1,176 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/02/. It is a snapshot of the page as it appeared on Dec 6, 2011 23:15:10 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + February | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: February 2011

+ + +
+ +

Questions about copyright of the deceased

+ + + + +
+

I recently acquired a fairly recent printing of Why We Can’t Wait by Martin Luther King Junior. Now, I assumed that the copyright of the book would have passed to either his children, or some foundation. However, feeling curious I … Continue reading

+ +
+ + +
+ + + Posted in Uncategorized + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/02/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/02/index.html new file mode 100644 index 0000000..e471325 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/02/index.html @@ -0,0 +1,173 @@ + + + + + February | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: February 2011

+ + +
+ +

Questions about copyright of the deceased

+ + + + +
+

I recently acquired a fairly recent printing of Why We Can’t Wait by Martin Luther King Junior. Now, I assumed that the copyright of the book would have passed to either his children, or some foundation. However, feeling curious I … Continue reading

+ +
+ + +
+ + + Posted in Uncategorized + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.chtml new file mode 100644 index 0000000..968033a --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.chtml @@ -0,0 +1,225 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/. It is a snapshot of the page as it appeared on Dec 7, 2011 22:00:37 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + Questions about copyright of the deceased | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Questions about copyright of the deceased

+ +
+

I recently acquired a fairly recent printing of Why We Can’t Wait by Martin Luther King Junior. Now, I assumed that the copyright of the book would have passed to either his children, or some foundation. However, feeling curious I decided to check.

+

Following is the copyright page at the beginning of the book. I’ve collapsed some sections that are not relevant to my question into [...]. Emphasis mine.

+

+SIGNET CLASSICS
+Published by New American Library, [...]

+

Penguin Books, Ltd., [...]

+

Published by Signet Classics, [...]

+

First Signet Classics Printing, January 2000
+30 29 28 27 26 25 24 23 22 21

+

Copyright © Martin Luther King, Jr., 1963, 1964
+Introduction copyright © Reverend Jesse L. Jackson, Sr., 2000
+All rights reserved

+

Printed in the United States of America

+

Without limiting the rights under copyright reserved above, no part of this
+publication may be reproduced, stored in or introduced int a retrieval system,
+or transmitted, in any form, or by any means (electronic, mechanical, photo-
+copying, recording, or otherwise), without prior written permission of both
+the copyright owner
and the above publisher of this book.

+

If you purchased this book without a cover [...]

+

The scanning, uploading, and distribution of this book via the Internet of via
+any other means without permission of the publisher is illegal and punish-
+able by law.
Please purchase only authorized electronic editions, and do not
+participate in or encourage electronic piracy of copyrighted materials. Your sup-
+port of the author’s rights is appreciated.
+

+

(To those who will comment on it, my posting of the above text is firmly within fair use.)

+

So, my questions are:

+
    +
  • Is MLK still the copyright holder? Yes: Getting his permission is a little hard. No: Whose permission do I need?
  • +
  • Is distribution without permission of the publisher really illegal? What legal stake do they have to the text of the book? Isn’t it really the copyright holder’s permission I need? (for the text anyway, I’m not concerned about things like typesetting and cover art).
  • +
  • I find it humorous that they end their plea for me to not pirate the book with a thank you for supporting MLK’s rights. Because he totally appreciates his copyright to draw a profit from the book right now. Because he’s more concerned about other not making copies of the book than spreading the message, especially now that he’s dead, and can’t draw a profit from it anyway.
  • +
+ +
+
+ +
+ +
+ This entry was posted in Uncategorized. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.html new file mode 100644 index 0000000..ffa6446 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/02/questions-about-copyright-of-the-deceased/index.html @@ -0,0 +1,222 @@ + + + + + Questions about copyright of the deceased | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Questions about copyright of the deceased

+ +
+

I recently acquired a fairly recent printing of Why We Can’t Wait by Martin Luther King Junior. Now, I assumed that the copyright of the book would have passed to either his children, or some foundation. However, feeling curious I decided to check.

+

Following is the copyright page at the beginning of the book. I’ve collapsed some sections that are not relevant to my question into [...]. Emphasis mine.

+

+SIGNET CLASSICS
+Published by New American Library, [...]

+

Penguin Books, Ltd., [...]

+

Published by Signet Classics, [...]

+

First Signet Classics Printing, January 2000
+30 29 28 27 26 25 24 23 22 21

+

Copyright © Martin Luther King, Jr., 1963, 1964
+Introduction copyright © Reverend Jesse L. Jackson, Sr., 2000
+All rights reserved

+

Printed in the United States of America

+

Without limiting the rights under copyright reserved above, no part of this
+publication may be reproduced, stored in or introduced int a retrieval system,
+or transmitted, in any form, or by any means (electronic, mechanical, photo-
+copying, recording, or otherwise), without prior written permission of both
+the copyright owner
and the above publisher of this book.

+

If you purchased this book without a cover [...]

+

The scanning, uploading, and distribution of this book via the Internet of via
+any other means without permission of the publisher is illegal and punish-
+able by law.
Please purchase only authorized electronic editions, and do not
+participate in or encourage electronic piracy of copyrighted materials. Your sup-
+port of the author’s rights is appreciated.
+

+

(To those who will comment on it, my posting of the above text is firmly within fair use.)

+

So, my questions are:

+
    +
  • Is MLK still the copyright holder? Yes: Getting his permission is a little hard. No: Whose permission do I need?
  • +
  • Is distribution without permission of the publisher really illegal? What legal stake do they have to the text of the book? Isn’t it really the copyright holder’s permission I need? (for the text anyway, I’m not concerned about things like typesetting and cover art).
  • +
  • I find it humorous that they end their plea for me to not pirate the book with a thank you for supporting MLK’s rights. Because he totally appreciates his copyright to draw a profit from the book right now. Because he’s more concerned about other not making copies of the book than spreading the message, especially now that he’s dead, and can’t draw a profit from it anyway.
  • +
+ +
+
+ +
+ +
+ This entry was posted in Uncategorized. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/05/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/05/index.chtml new file mode 100644 index 0000000..172fd09 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/05/index.chtml @@ -0,0 +1,176 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/05/. It is a snapshot of the page as it appeared on Dec 6, 2011 12:14:59 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + May | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: May 2011

+ + +
+ +

Why `sed -i’ exists

+ + + + +
+

I’ve decided to to a morning-pages type thing here, just to get info out. This means that I’ll be posting 250-ish word weblog post snippits sharing whatever, and fairly frequently posting, if this works. So, what is the purpose of … Continue reading

+ +
+ + +
+ + + Posted in Computers, morning-pages + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/05/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/05/index.html new file mode 100644 index 0000000..73a1f12 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/05/index.html @@ -0,0 +1,173 @@ + + + + + May | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: May 2011

+ + +
+ +

Why `sed -i’ exists

+ + + + +
+

I’ve decided to to a morning-pages type thing here, just to get info out. This means that I’ll be posting 250-ish word weblog post snippits sharing whatever, and fairly frequently posting, if this works. So, what is the purpose of … Continue reading

+ +
+ + +
+ + + Posted in Computers, morning-pages + + | + + + Leave a comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml new file mode 100644 index 0000000..e853748 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.chtml @@ -0,0 +1,198 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/. It is a snapshot of the page as it appeared on Dec 15, 2011 08:37:11 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + Why `sed -i’ exists | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Why `sed -i’ exists

+ +
+

I’ve decided to to a morning-pages type thing here, just to get info out. This means that I’ll be posting 250-ish word weblog post
+snippits sharing whatever, and fairly frequently posting, if this works.

+

So, what is the purpose of the -i flag to sed? Simply, it edits the file in place, instead of dumping the edit to stdout.

+

Those of you familiar with “cat -v Considered Harmful” or just traditional UNIX design will say “bah, what a useless flag, just use sed 's/regex//' < file > file to write the changes back to the file.

+

But there’s a problem with this. There is a race condition, the file has been opened twice, once for reading, and once for writing. If they get closed in the wrong order, you will end up with an empty file. In my experience this very seldom happens. However, when you have a shell script that usually works, but just occaisionally corrupts your `database’, you’ll see why sed -i‘s important.

+ +
+
+ +
+ +
+ This entry was posted in Computers, morning-pages. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.html new file mode 100644 index 0000000..d1955af --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/05/why-sed-i-exists/index.html @@ -0,0 +1,195 @@ + + + + + Why `sed -i’ exists | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Why `sed -i’ exists

+ +
+

I’ve decided to to a morning-pages type thing here, just to get info out. This means that I’ll be posting 250-ish word weblog post
+snippits sharing whatever, and fairly frequently posting, if this works.

+

So, what is the purpose of the -i flag to sed? Simply, it edits the file in place, instead of dumping the edit to stdout.

+

Those of you familiar with “cat -v Considered Harmful” or just traditional UNIX design will say “bah, what a useless flag, just use sed 's/regex//' < file > file to write the changes back to the file.

+

But there’s a problem with this. There is a race condition, the file has been opened twice, once for reading, and once for writing. If they get closed in the wrong order, you will end up with an empty file. In my experience this very seldom happens. However, when you have a shell script that usually works, but just occaisionally corrupts your `database’, you’ll see why sed -i‘s important.

+ +
+
+ +
+ +
+ This entry was posted in Computers, morning-pages. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.chtml new file mode 100644 index 0000000..f80c28f --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.chtml @@ -0,0 +1,231 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/. It is a snapshot of the page as it appeared on Dec 15, 2011 07:15:39 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + [Emacs] autopair problems when using term-mode | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

[Emacs] autopair problems when using term-mode

+ +
+

I found this awesome blog post on the Korean blog Seorenn SIGSEGV.

+

Using Google translate, I was able to extract the information I needed. However, Google translate quite botched it, as did Yahoo and Bing translate. I’ve used a combination of these three tools, and my understanding of Emacs, to put together a more reasonable translation.

+

I’m posting the full English text of it here because this is a problem I’ve had, and would like to help others find the solution. I don’t mean to rip off the original author, his blog seems quite good, worth reading, if you don’t mind poor translations (or, can read Korean).

+

The original post can be found here here.

+

+In Emacs term-mode (M-x term) and multi-term-mode pressing the Enter key causes an error to appear in the mini-buffer, and the keystroke appears to have been eaten.

+

This problem only occurs when using autopair. are thought to In addition to or RET (Enter) as a separate feature for all modes of binding may also occur. if autopair the last of the solution are presented.

+

See below sum up shoveling machine.

+

Issue

+

During term-mode RET does not work. The mini-buffer shows the error message Wrong type argument: characterp, return. RET has been bound to something here, or maybe you saw the state I had a feeling heard nil.

+

Alternative

+

Fortunately, I was able to replace the RET key with C-j. This is used as a temporary measure to work with.

+

Cause Analysis

+

In term-mode use C-h k to find the function that RET is bound to. autopair that certain functions were bound.

+

As a result, be sure that autopair is the culprit.

+

Attempted Solution

+

In term-mode C-h k with C-j to determine the function bound to: term-send-raw.

+

In conclusion, I believe you will solve the problem in the RET key bindings by using define-key to bind the key to term-send-raw in term-mode-map.

+

But the code encounters an error. Is not allowed to do something it felt like.

+

Solution

+

The code below. Not two lines were able to solve it.

+
+(add-hook 'term-mode-hook
+  #'(lambda () (setq autopair-dont-activate t)))
+
+

Source of the above code: http://emacs-fu.blogspot.com/2010/06/console-apps-in-emacs-with-multi-term.html +

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+ +

One Response to [Emacs] autopair problems when using term-mode

+ +
    + +
  1. +

    Pingback: Fixing “Wrong type argument: characterp, return” in !Emacs | ltsBlog

    + +
  2. + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.html new file mode 100644 index 0000000..f127117 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/emacs-autopair-problems-when-using-term-mode/index.html @@ -0,0 +1,228 @@ + + + + + [Emacs] autopair problems when using term-mode | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

[Emacs] autopair problems when using term-mode

+ +
+

I found this awesome blog post on the Korean blog Seorenn SIGSEGV.

+

Using Google translate, I was able to extract the information I needed. However, Google translate quite botched it, as did Yahoo and Bing translate. I’ve used a combination of these three tools, and my understanding of Emacs, to put together a more reasonable translation.

+

I’m posting the full English text of it here because this is a problem I’ve had, and would like to help others find the solution. I don’t mean to rip off the original author, his blog seems quite good, worth reading, if you don’t mind poor translations (or, can read Korean).

+

The original post can be found here here.

+

+In Emacs term-mode (M-x term) and multi-term-mode pressing the Enter key causes an error to appear in the mini-buffer, and the keystroke appears to have been eaten.

+

This problem only occurs when using autopair. are thought to In addition to or RET (Enter) as a separate feature for all modes of binding may also occur. if autopair the last of the solution are presented.

+

See below sum up shoveling machine.

+

Issue

+

During term-mode RET does not work. The mini-buffer shows the error message Wrong type argument: characterp, return. RET has been bound to something here, or maybe you saw the state I had a feeling heard nil.

+

Alternative

+

Fortunately, I was able to replace the RET key with C-j. This is used as a temporary measure to work with.

+

Cause Analysis

+

In term-mode use C-h k to find the function that RET is bound to. autopair that certain functions were bound.

+

As a result, be sure that autopair is the culprit.

+

Attempted Solution

+

In term-mode C-h k with C-j to determine the function bound to: term-send-raw.

+

In conclusion, I believe you will solve the problem in the RET key bindings by using define-key to bind the key to term-send-raw in term-mode-map.

+

But the code encounters an error. Is not allowed to do something it felt like.

+

Solution

+

The code below. Not two lines were able to solve it.

+
+(add-hook 'term-mode-hook
+  #'(lambda () (setq autopair-dont-activate t)))
+
+

Source of the above code: http://emacs-fu.blogspot.com/2010/06/console-apps-in-emacs-with-multi-term.html +

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+ +

One Response to [Emacs] autopair problems when using term-mode

+ +
    + +
  1. +

    Pingback: Fixing “Wrong type argument: characterp, return” in !Emacs | ltsBlog

    + +
  2. + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.chtml new file mode 100644 index 0000000..6739755 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.chtml @@ -0,0 +1,202 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/. It is a snapshot of the page as it appeared on Dec 16, 2011 06:35:41 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + Fixing “Wrong type argument: characterp, return” in !Emacs | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Fixing “Wrong type argument: characterp, return” in !Emacs

+ +
+

A few months ago, I ran into an issue with Emacs that I just found the solution to. In Emacs term-mode (or ansi-term, or multi-term), hitting Enter doesn’t work, and the mini-buffer displays Wrong type argument: characterp, return, and the term doesn’t see the keystroke.

+

I dented about it on identi.ca, and no one was able to help me. This turned out to be a mistake, because I kept seeing the dent as I Googled/DuckDuckGo’ed for a solution.

+

Anyway, I finally found the solution on the Korean blog Seorenn SIGSEGV.

+

The problem is basically that autopair had remapped the return key to an autopair function, which didn’t jive with term-mode. At least, that’s what Seorenn said.

+

If it were that simple, I would have noticed it when I installed autopair. Only in some environments does the problem manifest. For example, on Ubuntu, where I started using autopair, the problem never appears. When I switched to Fedora (and later Parabola), I figured it was some issue with the X server, because it worked fine when running in a terminal.

+

Now knowing that the problem was related to autopair, I can’t figure out how it ever worked.

+

Anyway, the fix is to add the following to your .emacs:

+
(add-hook 'term-mode-hook
+  #'(lambda () (setq autopair-dont-activate t)))
+

(Code segment from emacs-fu, via Seorenn SIGSEGV.)

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.html new file mode 100644 index 0000000..b106c0e --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/fixing-wrong-type-argument-characterp-return-in-emacs/index.html @@ -0,0 +1,199 @@ + + + + + Fixing “Wrong type argument: characterp, return” in !Emacs | ltsBlog + + + + + + + + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + +
+ + + +
+

Fixing “Wrong type argument: characterp, return” in !Emacs

+ +
+

A few months ago, I ran into an issue with Emacs that I just found the solution to. In Emacs term-mode (or ansi-term, or multi-term), hitting Enter doesn’t work, and the mini-buffer displays Wrong type argument: characterp, return, and the term doesn’t see the keystroke.

+

I dented about it on identi.ca, and no one was able to help me. This turned out to be a mistake, because I kept seeing the dent as I Googled/DuckDuckGo’ed for a solution.

+

Anyway, I finally found the solution on the Korean blog Seorenn SIGSEGV.

+

The problem is basically that autopair had remapped the return key to an autopair function, which didn’t jive with term-mode. At least, that’s what Seorenn said.

+

If it were that simple, I would have noticed it when I installed autopair. Only in some environments does the problem manifest. For example, on Ubuntu, where I started using autopair, the problem never appears. When I switched to Fedora (and later Parabola), I figured it was some issue with the X server, because it worked fine when running in a terminal.

+

Now knowing that the problem was related to autopair, I can’t figure out how it ever worked.

+

Anyway, the fix is to add the following to your .emacs:

+
(add-hook 'term-mode-hook
+  #'(lambda () (setq autopair-dont-activate t)))
+

(Code segment from emacs-fu, via Seorenn SIGSEGV.)

+ +
+
+ +
+ +
+ This entry was posted in Computers. Bookmark the permalink. + +
+
+ + + + + +
+
+

Leave a Reply

+
+

Your email address will not be published. Required fields are marked *

*

+ +

+

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

+ + + +

+
+
+ +
+ +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/index.chtml b/web/lukeshu.ath.cx/1/wordpress/2011/08/index.chtml new file mode 100644 index 0000000..737de42 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/index.chtml @@ -0,0 +1,205 @@ + +
This is Google's cache of http://lukeshu.ath.cx/1/wordpress/2011/08/. It is a snapshot of the page as it appeared on Dec 12, 2011 01:22:46 GMT. The current page could have changed in the meantime. Learn more

+
 
+ + + + + August | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: August 2011

+ + +
+ +

Fixing “Wrong type argument: characterp, return” in !Emacs

+ + + + +
+

A few months ago, I ran into an issue with Emacs that I just found the solution to. In Emacs term-mode (or ansi-term, or multi-term), hitting Enter doesn’t work, and the mini-buffer displays Wrong type argument: characterp, return, and the … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + Leave a comment + +
+ +
+ +
+ +

[Emacs] autopair problems when using term-mode

+ + + + +
+

I found this awesome blog post on the Korean blog Seorenn SIGSEGV. Using Google translate, I was able to extract the information I needed. However, Google translate quite botched it, as did Yahoo and Bing translate. I’ve used a combination … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + 1 Comment + +
+ +
+ + + +
+ + + + + + diff --git a/web/lukeshu.ath.cx/1/wordpress/2011/08/index.html b/web/lukeshu.ath.cx/1/wordpress/2011/08/index.html new file mode 100644 index 0000000..ad59fb8 --- /dev/null +++ b/web/lukeshu.ath.cx/1/wordpress/2011/08/index.html @@ -0,0 +1,202 @@ + + + + + August | 2011 | ltsBlog + + + + + + + + + + + + + + + + + +

ltsBlog

+ + + + + + + + + + + + +
+ + + +

Monthly Archives: August 2011

+ + +
+ +

Fixing “Wrong type argument: characterp, return” in !Emacs

+ + + + +
+

A few months ago, I ran into an issue with Emacs that I just found the solution to. In Emacs term-mode (or ansi-term, or multi-term), hitting Enter doesn’t work, and the mini-buffer displays Wrong type argument: characterp, return, and the … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + Leave a comment + +
+ +
+ +
+ +

[Emacs] autopair problems when using term-mode

+ + + + +
+

I found this awesome blog post on the Korean blog Seorenn SIGSEGV. Using Google translate, I was able to extract the information I needed. However, Google translate quite botched it, as did Yahoo and Bing translate. I’ve used a combination … Continue reading

+ +
+ + +
+ + + Posted in Computers + + | + + + 1 Comment + +
+ +
+ + + +
+ + + + + + -- cgit v1.2.3-2-g168b