Browse Source

Merge pull request #308 from herby/global-result

Global variable `result` not created anymore.
Nicolas Petton 11 years ago
parent
commit
70e78a981d
3 changed files with 12 additions and 23 deletions
  1. 5 10
      js/Kernel-Objects.deploy.js
  2. 6 11
      js/Kernel-Objects.js
  3. 1 2
      st/Kernel-Objects.st

+ 5 - 10
js/Kernel-Objects.deploy.js

@@ -661,16 +661,11 @@ smalltalk.addMethod(
 "_try_catch_",
 smalltalk.method({
 selector: "try:catch:",
-fn: function (aBlock, anotherBlock) {
-    var self = this;
-    try {
-        result = aBlock();
-    } catch (e) {
-        result = anotherBlock(e);
-    }
-    return result;
-    return self;
-}
+fn: function (aBlock,anotherBlock){
+var self=this;
+try{return aBlock()} catch(e) {return anotherBlock(e)};
+;
+return self}
 }),
 smalltalk.Object);
 

+ 6 - 11
js/Kernel-Objects.js

@@ -918,18 +918,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "try:catch:",
 category: 'error handling',
-fn: function (aBlock, anotherBlock) {
-    var self = this;
-    try {
-        result = aBlock();
-    } catch (e) {
-        result = anotherBlock(e);
-    }
-    return result;
-    return self;
-},
+fn: function (aBlock,anotherBlock){
+var self=this;
+try{return aBlock()} catch(e) {return anotherBlock(e)};
+;
+return self},
 args: ["aBlock", "anotherBlock"],
-source: "try: aBlock catch: anotherBlock\x0a\x09<try{result = aBlock()} catch(e) {result = anotherBlock(e)};\x0a\x09return result;>",
+source: "try: aBlock catch: anotherBlock\x0a\x09<try{return aBlock()} catch(e) {return anotherBlock(e)}>",
 messageSends: [],
 referencedClasses: []
 }),

+ 1 - 2
st/Kernel-Objects.st

@@ -205,8 +205,7 @@ throw: anObject
 !
 
 try: aBlock catch: anotherBlock
-	<try{result = aBlock()} catch(e) {result = anotherBlock(e)};
-	return result;>
+	<try{return aBlock()} catch(e) {return anotherBlock(e)}>
 ! !
 
 !Object methodsFor: 'initialization'!