Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to use lambas as functions returning a result #19874

Closed
2 tasks
lv37 opened this issue Nov 14, 2023 · 1 comment · Fixed by #20433
Closed
2 tasks

Add the ability to use lambas as functions returning a result #19874

lv37 opened this issue Nov 14, 2023 · 1 comment · Fixed by #20433
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.

Comments

@lv37
Copy link
Contributor

lv37 commented Nov 14, 2023

Describe the feature

It should be possible to use a lambda as a function returning a result

module main

fn main() {
	take_lambda(|| println('abc'))
}

fn take_lambda(l fn () !) {
	l() or { panic(err) }
}

Use Case

Makes it easier to create functions that return results

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.3 7c0aed1

Environment details (OS name and version, etc.)

V full version: V 0.4.3 4628fe7.7c0aed1
OS: linux, Linux version 6.5.11-300.fc39.x86_64 (mockbuild@d23353abed4340e492bce6e111e27898) (gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), GNU ld version 2.40-13.fc39) #1 SMP PREEMPT_DYNAMIC Wed Nov  8 22:37:57 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz

getwd: /home/user/Projects/v-testing/webview
vexe: /home/user/.local/lib/v/v
vexe mtime: 2023-11-15 12:36:47

vroot: OK, value: /home/user/.local/lib/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /tmp/v_1002

Git version: git version 2.41.0
Git vroot status: weekly.2023.45.1-39-g7c0aed16
.git/config present: true

CC version: cc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@lv37 lv37 added the Bug This tag is applied to issues which reports bugs. label Nov 14, 2023
@ArtemkaKun ArtemkaKun added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Nov 14, 2023
@shove70
Copy link
Contributor

shove70 commented Nov 15, 2023

Looks like a feature request

@shove70 shove70 added Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one. and removed Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 15, 2023
@lv37 lv37 changed the title Cannot use lambda as function returning result Add the ability to use lambas as functions returning a result Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature/Enhancement Request This issue is made to request a feature or an enhancement to an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants