I meant `bool` instead of `void`. On Monday, August 3, 2020 at 7:51:51 PM UTC+5:30 Timmy Jose wrote:
> > Hello, > > I've been trying to learn ATS from the official tutorials, and while I > like the language so far, and think that it is quite logical (if different > from many other languages in the same categories), one thing that keeps > annoying me is getting some strange error messages. > > For instance, why is this a problem: > > fun > bstree_search ( > t0: bstree, > k0: string > ): bool = > case+ t0 of > | E () => false, > | B (t1, k, t2) => > let val sgn = compare (k0, k) > in case+ 0 of > | _ when sgn < 0 => bstree_search (t1, k0) > | _ when sgn > 0 => bstree_search (t2, k0) > | _ => true > end > > I would expect that the return types of all sub-expressions are `void` > anyway, so why does the compiler complain: > > $ patscc -DATS_MEMALLOC_LIBC -o bst bst.dats && ./bst > /Users/z0ltan/dev/study/ats/introduction_to_programming_in_ats/chapter4/bst.dats: > > 1022(line=53, offs=22) -- 1023(line=53, offs=23): error(parsing): the token > is discarded. > /Users/z0ltan/dev/study/ats/introduction_to_programming_in_ats/chapter4/bst.dats: > > 1096(line=56, offs=9) -- 1098(line=56, offs=11): error(parsing): the token > is discarded. > exit(ATS): uncaught exception: > _2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025) > > The ATS FAQ recommends wrapping expressions with parentheses for such > errors, but doing so in this case does not get rid of the errors, and > secondly why is that even needed? > > Right now, this is the biggest thing that keeps tripping me up - seemingly > random "token discarded" error messages as well as some strange "} keyword > needed" error message etc. Experimenting randomly seems to fix them most > times, but is there any reason to this madness? > > Can anyone give me general guidelines to avoid seeing these sort of > trivial errors? > > Best, > > Timmy > -- You received this message because you are subscribed to the Google Groups "ats-lang-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/1c696dbd-6963-4af7-81ec-be6854d0a077n%40googlegroups.com.
