#689 More symbol value type inference?

tompalmer Sat 25 Jul 2009

I was just wondering if the previously discussed symbol type inference (e.g., @whatever.val) should be extended to use with facets (e.g., slot.facet(@whatever)) or maybe even maps (e.g., map[@whatever]). It could make them very powerful as general-use schema-friendly keys.

I'm not 100% sure this is a good idea. I was just thinking about it.

As a side note, in the map case, it could be interesting to see about getting the default value to apply automatically in some fashion, but that might need operator overloading. Again, just some thoughts.

tompalmer Sat 25 Jul 2009

After understanding the new usage of symbol default values, my comment on that above for maps is probably not very meaningful. (But the type inference part might still be interesting.)

brian Sun 26 Jul 2009

Interesting idea, but I'm not sure I really want to start pushing that boundary - trying to make the compiler aware of API semantics so that it can infer that the resulting type might be. Although it might be interesting thought exercise to consider annotating methods like that with some facets that the compiler could use (maybe as a generics lite sort of type system).

cheeser Mon 27 Jul 2009

Take up your lightsaber! Strike me down and your journey to the dark side will be complete!

brian Mon 27 Jul 2009

I think what you are asking for already works:

fansh> [@uriScheme.val].type
sys::Str[]

Login or Signup to reply.