f# - Why is using the base key word causing this error? -
i trying example programming f# o'railey, chris smith page 53.
it working functions returning functions.
this line straight book in vs2013 ide editor, fsi , linqpad4 giving error:
code:
let generatepoweroffunc base = (fun exponent -> base ** exponent)
error:
error fs0010: unexpected keyword 'base' in pattern
what missing or there author did not include needs included.
i suspect it's merely matter of base
not being keyword when book written.
try different identifier:
let generatepoweroffunc b = (fun exponent -> b ** exponent)
assuming you've got 2009 edition of programming f#, before f# 2.0 released (although after 1.0). i'm trying find out when introduced keyword...
edit: actually, looking @ this version of spec written in 2009, looks base
keyword @ point. wonder whether original code written before book published.
either way, think it's reasonable treat error, , using valid identifier instead should fine.
edit: it's listed in book's errata:
example 3-3 not work as-is in vs 2010. "base" apparently keyword, should have been escaped or there voodoo make not keyword i've missed in book. line 2 of example should this:
let generatepoweroffunc ``base`` = (fun exponent -> ``base`` ** exponent);;
alternatively, different variable name should chosen.
note author or editor:
feedback, must have missed keyword being marked reserved late in product cycle.in future version of book i'll have read:
let generatepoweroffunc basevalue = (fun exponent -> basevalue ** exponent);;
Comments
Post a Comment