scala - restrict implicit parameter resolution scope -


i find need write function inner recursive helper function, , takes same parameter list outer function, additional accumulator argument:

def encode(tree : tree, text: string):string = {     def rec(tree: tree, text:string, result:string):string = ???      rec(tree, text, "") }  

i want simplify :

def encode(tree : tree, text: string)(implicit result:string = "" ):string 

this can remove inner function definition, has problem of that, see if need call function lookup inside encode, , lookup takes implicit parameter of type string, implicit result:string = "" implicitly pass lookup function.

 def lookup(tree : tree, text: string)(implicit result:string = "" ):string 

i don't want happen, there way restrict implicit parameter in lookup resolving outside of function? or other better ideas?

how using normal default argument instead , passing accumulator explicitly in implementation:

def encode(tree : tree, text: string, result : string = "" ): string = {   //snip   encode(new_tree, new_text, new_result) }  // call encode(my_tree, my_text) 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -