[erlang-questions] Erlang / C# The Best Interface
Tim Watson
watson.timothy@REDACTED
Wed Jan 19 12:35:30 CET 2011
> So for the first case you should do Request(new object[] {
> “’insert_person’”, “Ivan”, “26”}); %% new object[] means new tuple { }
>
> So if you use Request(params object[]) -> Request(“’insert_person’”,
> “Ivan”, “26”) to make a tuple then how you send the simple ‘logoff’ atom?
>
How about this:
Request(params ErlangObject Input) {
// do the rpc
}
static ErlangTuple Tuple(this Object self, params object[] argv) {
return new ErlangTuple(argv);
}
static ErlangAtom Atom(this Object self, string s) {
return new ErlangAtom(s);
}
// etc
And then you could write the call site like so (accounting for the
fancy pants static import-alike in .NET):
var result = req.Request(Atom("i_like_foo"));
// or
var result = req.Request(Tuple(Atom("insert_person"), "Ivan", 26));
// or
var result = req.Request(Tuple(Atom("insert_person"), List("Ivan", 26)));
Where strings and numbers and other .NET value types are handled
automatically but tuples, lists and atoms take a constructor and are a
wrapper type.
Just a thought!
Cheers,
Tim
More information about the erlang-questions
mailing list