Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

JIT, optimization, data structures

Name: Anonymous 2011-10-21 11:02

Little Ive writes the following code in a dynamically typed programming language called Anus that features a GC and JIT.

var make_tuple = function(x,y){
  return function(i){
    return (i==0) ? x : y;
  }
}


Little Ive then calls the function make_tuple repeatedly with int32 in a tight loop, and sometimes also calls it with other arguments of other types as well.

How should Anus optimize this?  Discuss the situation and its complexities.

Name: Anonymous 2011-10-21 11:17

>>1
Anus is broken because JIT and GC are not language features, but implementation details.

Name: Anonymous 2011-10-21 11:20

>>2
Anus seems to be one of those new and hype ``Open Source'' ``Web languages'' which are defined by their reference implementations. Yet another terrible reinvention of the, already bad, JavaScript language.

Name: Anonymous 2011-10-21 12:39

>>3
defined by their reference implementations

because BDUF is so much better.

>>1

var make_tuple = function(x,y){
  return function(f) {
    return f(x,y);
  }
}
var left = function(x,y) return x;
var right = function(x,y) return y;

Name: Anonymous 2011-10-21 13:39

JIT
IT'S COMPILED BUT IT'S NOT REALLY COMPILED BUT IT'S KINDA INTERPRETED BUT IT ISN'T REALLY INTERPRETED

Name: Anonymous 2011-10-21 13:39

>>1
Since it is a dynamic typed language, I'm assuming it's also using tagged pointers, and a sane encoding for word-sized integers (INTVALUE|0, where INTVALUE is a WORDSIZE-1 signed integer value, and the 0 to distinguish between immediate integers and pointers).
So, i == 0 would be an actual test for zero, no need to even check whether i is an integer, assuming that == just returns false on type mismatch (which is probably so, in a JS-like language), or no other numerical types (unlikely), or that 0.0 != 0 (again unlikely), or that the other arguments of other types are not numerical or can't be a non-integer zero (possible).

Name: Anonymous 2011-10-21 14:18

>>5
It's compiled, just not AOT.

Name: Anonymous 2011-10-21 15:55

>>2-3,5-7
Entirely predictable.

Name: Anonymous 2011-10-21 18:02

assuming that == just returns false on type mismatch (which is probably so, in a JS-like language)
wat

Name: Anonymous 2011-10-22 10:07

>>7
SO YEAH IT'S KINDA COMPILED

Name: Anonymous 2011-10-22 10:44

>>9
Isn't == (or ===) like equal? in Scheme?

>>10
No, it is compiled.

Name: Anonymous 2011-10-22 12:40

The language should disallow such silly constructs by not supporting closures, first-class functions or even dynamic typing.
The programmer will then rewrite it to the much more efficient:
struct tuple {
  int x, y;
};
struct tuple make_tuple(int x, int y) {
  return (struct tuple) {x, y};
}

Name: Anonymous 2011-10-22 13:15

>>12
fuck off

Name: Anonymous 2011-10-22 13:35

>>12


Interface BinaryTuppleAccessorable<TuppleType> {
  public TuppleType get(TuppleType value1, TuppleType value2);
}

Interface BinaryTuppleable<TuppleType> {
  public TuppleType runAccessor(BinaryTuppleAccessorable<TuppleType> accessor);
}

class BinaryTupple<TuppleType> implements BinaryTuppleable<TuppleType> {
  BinaryTupple(TuppleType value1, TuppleType value2) {
    this.value1 = value1;
    this.value2 = value2;
  }
  @Override
  public TuppleType runAccessor(BinaryTuppleAccessorable<TuppleType> accessor) {
    return accessor.get(value1, value2);
  }

  private TuppleType value1;
  private TuppleType value2;
}

class BinaryTuppleLeftAccessor<TuppleType> implements BinaryTuppleAccessorable<TuppleType> {
  @Override
  public TuppleType get(TuppleType value1, TuppleType value2) {
    return value1;
  }
}

class BinaryTuppleRightAccessor<TuppleType> implements BinaryTupplerAccessorable<TuppleType> {
  @Override
  public TuppleType get(TuppleType value1, TupplerType value2) {
    return value2;
  }
}

class Demo {
  BinaryTupple<Integer> a = new BinaryTupple<Integer>(5,6);
  Integer la = a.get(new BinaryTuppleLeftAccessor<Integer>()); // la == 5
  Integer lb = a.get(new BinaryTuppleRightAccessor<Integer>()); // la == 5
}

Name: Anonymous 2011-10-22 14:33

>>12
#include <ooc/lang/Tuple.h>

Name: Anonymous 2011-10-22 15:46

Anus
GC

GC is shit

Name: Anonymous 2011-10-22 16:01

>>16
fuck off and die you cock sucking piece of shit

Name: Anonymous 2013-08-31 7:04



This is kind of a good idea, since I thought the 3D feature was pointless, but

Name: Anonymous 2013-08-31 7:48


 Because you know her personally to call her that? One woman wroned you and you assume all Japanese women are like that? I don't get your hatred and perverstion anon.

Name: Anonymous 2013-08-31 8:34


 Its actually bad luck to do this

Name: Anonymous 2013-08-31 9:20


This is the fourth in this series of threads. The number doesn't matter much but is here because it's a nice thing to keep track of.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List