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

If syntax sugar #727

Open
emil14 opened this issue Oct 4, 2024 · 2 comments
Open

If syntax sugar #727

emil14 opened this issue Oct 4, 2024 · 2 comments
Assignees

Comments

@emil14
Copy link
Collaborator

emil14 commented Oct 4, 2024

See #724

$bool -> if {
    then -> receiver_1
    else -> receiver_1
}

Before

flow Main(start) (stop) {
	Println, Gt<int>, If
	---
	:start -> [
		(10 -> gt:compared),
		(50 -> gt:actual)
	]
	gt -> if
	if:then -> ('Actual is greater' -> println -> :stop)
	if:else -> ('Actual is lower' -> println -> :stop)
}

After

flow Main(start) (stop) {
	Println, Gt<int>
	---
	:start -> [
		(10 -> gt:compared),
		(50 -> gt:actual)
	]
	gt -> if {
	    then -> ('Actual is greater' -> println -> :stop)
	    else -> ('Actual is lower' -> println -> :stop)
	}
}
@emil14
Copy link
Collaborator Author

emil14 commented Oct 28, 2024

Without incoming ->

def Main(start) (stop) {
	Println, Gt<int>
	---
	if (10 == 50) {
	    then -> ('Actual is greater' -> println -> :stop)
	    else -> ('Actual is lower' -> println -> :stop)
	}
}

About if-else branching

I was thinking about if {...} else {...} but there's a problem - we need to route signal from then/else outports to trigger downstream nodes, i.e. we need then -> and else -> stuff

PROBLEM

How should it work with deferred connections? We just omitted :start here!

@emil14
Copy link
Collaborator Author

emil14 commented Nov 3, 2024

Maybe match switch is enough?

If match will allow not only to select value but also trigger branch (routing), then if is barely needed

v -> switch {
  true -> ...
  false -> ...
}

Vs if-else

v -> if {
  then -> ...
  else -> ...
}

See #291 #725 for more details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant