Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type inference #26

Open
julochrobak opened this issue Dec 19, 2012 · 0 comments
Open

type inference #26

julochrobak opened this issue Dec 19, 2012 · 0 comments

Comments

@julochrobak
Copy link
Member

The type inference for function arguments and result type would increase the code reuse of user defined Bandicoot functions dramatically.

Here is an example of a function which takes one relation parameter and returns a relation as well. The function requires the input argument to have a string attribute called "quality". It could work on any relations which match this criteria and therefor the following code reuse would be possible:

fn GoodProducts(b) {
    return select (quality == "good") b;
}

var books {title string, price real, quality string}
var cars {vendor string, name string, quality string}

fn GoodCars() {
    return GoodProducts cars;
}

fn GoodBooks() {
    return GoodProducts books;
}

This would make Bandicoot also very practical in scenarios where the data structure is not completely known, yet a calculation is needed or some information needs to be persisted and the rest of the data just flows through.

Here is an example of an HTTP service which captures the users and leaves the rest of the data untouched:

var users {user string};

fn CaptureUsers(in) {
    users += project (user) in;

    return in;
}

Any CSV tabular data could be piped through this function which contains the "user" column, for example capturing users for orders and processing them further:

cat orders.csv | \
    curl --data-binary @- http://localhost:12345/CaptureUsers | \
    ... some other processing of the orders.csv file ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant