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

Single call inline chain fails #51

Closed
jariji opened this issue Apr 9, 2023 · 4 comments · Fixed by #54
Closed

Single call inline chain fails #51

jariji opened this issue Apr 9, 2023 · 4 comments · Fixed by #54
Assignees

Comments

@jariji
Copy link

jariji commented Apr 9, 2023

julia> @chain abs(1) 
ERROR: LoadError: Can't insert a first argument into:
1.

I'm interactively building a chain one step at a time, so I want to initially evaluate the first step. The block version works

@chain abs(1) begin
    
end # 1

just not the inline version.

@jkrumbiegel jkrumbiegel self-assigned this Apr 10, 2023
@jariji
Copy link
Author

jariji commented Feb 20, 2024

Bump

@jkrumbiegel
Copy link
Owner

jkrumbiegel commented Feb 21, 2024

I've been thinking a bit about this. There are currently three different modes supported:

Inline:

@chain a b c

Block with prefix argument (original syntax):

@chain a begin
    b
    c
end

Block without prefix:

@chain begin
    a
    b
    c
end

So my thought is that the original syntax is kind of a combination of the other two, and it seems to me in principle there's just one mode, but it's currently not implemented that way. That one mode would be inline like @chain a b c but if there's a begin end block as one of the arguments, it is flattened. The difference between that and what we currently have is that if we apply that consistently, we kind of change the behavior for things like @chain a b begin something end because nothing keeps one of the later inline arguments from being a begin end block. On the other hand, I feel like that is rather a design gap that I would want to close, and would probably merit going to a next minor version.

In that new mode you could then do stuff like this as well if you wanted to:

@chain a b begin
    c
    d
end e f

@jariji
Copy link
Author

jariji commented Feb 21, 2024

Fwiw I don't really like the "block without prefix" form, it seems like a weird special case. Compatibility aside, wouldn't it be simpler to just say the options are

@chain data block
@chain data expr...

@jkrumbiegel
Copy link
Owner

It may be simpler in some ways, but the single block style was introduced because some users had long first variable names that looked cluttered inline with the @chain begin. And so yeah, for compatibility it has to stay that way. And then I find having three different syntax styles more complicated than having one that the others derive from. For 99% of users it will make no difference either way.

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

Successfully merging a pull request may close this issue.

2 participants