jak-project/goal_src
water111 ef23fecd90
[goalc] default to non-immediate lambdas if not requested (#2604)
This fixes a long time issue with `lambda`. The `lambda` is a bit
overloaded in OpenGOAL: it's used in the implementation of `let`, and
also to define local anonymous functions.

```
(defmacro let (bindings &rest body)
  `((lambda :inline #t ,(apply first bindings) ,@body)
    ,@(apply second bindings)))
```

```
(defmacro defun (name bindings &rest body)
  (let ((docstring ""))
    (when (and (> (length body) 1) (string? (first body)))
      (set! docstring (first body))
      (set! body (cdr body)))
    `(define ,name ,docstring (lambda :name ,name ,bindings ,@body))))
```

In the first case of a `let`, a `return` from inside the `let` should
return from the functioning containing the `let`, not the scope of the
`lambda`. In the second case, we should return from the lambda. The way
we told the different between these cases was if the `lambda` was used
"immeidately", in the head of an expression (like it would be for the
`let` macro). But, this falsely triggers when an anonymous function is
used immediately: eg
```
((lambda () (return #f)))
```
should generate and call a real x86 function that returns immediately.

This should fix some death/mission failed stuff in jak 2.
2023-04-30 19:00:27 -04:00
..
jak1 Initial Jak 2 Autosplit Support (#2239) 2023-04-30 17:38:05 -04:00
jak2 alternate method for scaling screen warp effects with aspect ratio (#2603) 2023-04-30 23:12:20 +01:00
user repl: add gameVersionFolder to repl-config for running the non-default version (#2463) 2023-04-11 17:57:20 -04:00
goal-lib.gc [goalc] default to non-immediate lambdas if not requested (#2604) 2023-04-30 19:00:27 -04:00
goos-lib.gs Create a new format for particle definitions (defpart) (#2572) 2023-04-29 11:01:47 -04:00