[Omake] short-circuit returns

Jason Hickey jyh at cs.caltech.edu
Thu Aug 9 15:53:28 PDT 2007


I must have the example wrong, but I can't reproduce this.  Here is  
the program I'm using.

is-tasty(x) =
    match $x
    case tasty
       value true
    default
       value false

new-tasty(x) =
    value $"$x pies"

get-tasty(args) =
	foreach(x, $(args))
		if $(is-tasty $(x))
			return $(x)
	return $(new-tasty 123)

println($(get-tasty yum not-tasty tasty-freeze))

Jason

On Aug 9, 2007, at 3:28 PM, Nathaniel Gray wrote:

> Hi guys,
>
> OMake 0.9.8.5 behaves differently than previous versions on some  
> return statements.  In particular, it seems to dislike returns that  
> exit early from functions.  So this function that used to work now  
> gives "Misplaced return statement" on the first return:
>
> get-tasty(args) =
> 	foreach(x, $(args))
> 		if $(is-tasty $(x))
> 			return $(x)
> 	return $(new-tasty 123)
>
> Is this expected behavior?
>
> Thanks,
> -n8
>
> --
> >>>-- Nathaniel Gray -- Caltech Computer Science ------>
> >>>-- Mojave Project -- http://mojave.cs.caltech.edu -->
>
>
> _______________________________________________
> Omake mailing list
> Omake at metaprl.org
> https://lists.metaprl.org/mailman/listinfo/omake

--
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257





More information about the Omake mailing list