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

investigate wrong external bind #12

Open
glathoud opened this issue Jul 26, 2018 · 2 comments
Open

investigate wrong external bind #12

glathoud opened this issue Jul 26, 2018 · 2 comments

Comments

@glathoud
Copy link
Owner

Below, why is get_mean_stddev bound to an external function using transfun's current implementation?

var get_mean = tfun.redinit( '0', '+' ).next( '/n' )
,  get_stddev = tfun
    .decl( 'mean_value', get_mean )
    .map( 'v-mean_value' )
    .map( 'v*v' )
    .sum()
    .next( 'Math.sqrt(current/(n-1))' )  // unbiased std dev estimation

// compute both mean and stddev at once
, get_mean_stddev = get_stddev
    .next( '{stddev:current, mean:mean_value}')
;
@glathoud
Copy link
Owner Author

...because of .decl( 'mean_value', get_mean )
...must have been the heat...

@glathoud glathoud reopened this Jul 28, 2018
@glathoud
Copy link
Owner Author

...but actually can be solved in a constructive manner: since #7 we already have inlining of some external functions (see fext, flatorize). We could also inline the code generated by transfun, i.e. appfuns, as long as:

  • they are not already used as appfuns to generate smart code, only as external functions.
  • the code produced only uses let and const, no var (slight change).

When all "checks" are passed, we can simply add ._tf_get_argname_arr and ._tf_get_bodycode as methods to the generated appfun, then examples like the one above will be fully inlined.

glathoud added a commit that referenced this issue Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant