Code Monkey home page Code Monkey logo

tink_anon's People

Contributors

back2dos avatar gama11 avatar kevinresol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tink_anon's Issues

Splat fields of fields?

var o:{a:Foo, b:Foo};

splat(o, _.foo); // or splat(o, 'foo'); or any similar syntax
// becomes:
var a = o.a.foo;
var b = o.b.foo;

Anon.merge() sometimes fails with `expected type should be struct or @:structInit`

db.Foo.select({ foo: Foo.foo }).next( o -> tink.Anon.merge( o, ref = transform(o.ref))); fails compilation with:

expected type should be struct or @:structInit.

These variants work though:

  • .next( o -> { var r = tink.Anon.merge( o, ref = transform(o.ref)) ); r; }
  • .next( o -> Success(tink.Anon.merge( o, ref = transform(o.ref))) )
  • .next( o -> o = tink.Anon.merge( o, ref = transform(o.ref)) )

I'm going to use the last one for the time being.

merge will print lot's of @Optional not set value

using tink.Anon;
using tink.CoreApi;

typedef DataServerListObj = {
	@:optional var from:Int;
	@:optional var to:Int;
}

typedef SType = {
	@:optional var infor:String;
}

class Main {
	function new() {}

	static public function main() {
		var obj:DataServerListObj = {from: 1};
		var st:SType = {infor: "d"};

		trace(obj);// { from: 1 } instead of   { from: 1 ,to:undefind};
		var m = obj.merge(st);

		trace(m); // I don't expected to=undefined here that I not set 
	}
}

Merge fails to recognise condition in expr

This does not work:

var a = {v: "none"};

function getResult(isYes:Bool)
	return tink.Anon.merge(a, isYes ? {v:"it works"} : {});

trace(getResult(true));
trace(getResult(false));

OTOH this works:

tink.Anon.merge(a, {v: isYes ? "it works" : ""});

I believe it is not trivial thing to fix (if even possible) so adding a compilation error and a notion to readme about this kinds of limitation would be useful.

Supports EitherType?

var o = EitherType<{i:1}, Array<{i:1}>> = merge(i = 1);

Could the macro be clever enough to figure out what to produce? If it can rule out impossible outputs (Array in this case) then it should be easy. Otherwise if the two types are both structures it might have to "try"...

Allow null-padding optional fields.

Ensuring the same runtime structure for anonymous objects of the same compile time structure generally makes life easier for JITs.

It also has a couple of adverse effects though, so it should be customizable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.