ohua-dev / ohuac

A standalone compiler for ohua algorithms
Eclipse Public License 1.0
1 stars 0 forks source link

Add support for ad hoc created tuples as return values #4

Closed Feliix42 closed 6 years ago

Feliix42 commented 6 years ago

As we discussed last week, supporting ad hoc constructed tuples as return values would prove benefitial and allow for an easier algorithm specification. The following (rather simple) example illustrates how the corresponding algorithm would look like.

ns some_ns;

use sf tuple_ret (calculate_string_length, splice_string);

fn main(input_string: String) -> (usize, String, usize) {
    let old_len = calculate_string_length(input_string);
    let spliced_str = splice_string(input_string);
    let new_len = calculate_string_length(spliced_str);

    (old_len, spliced_str, new_len)
}

I'm not quite sure, did we already discuss how to implement this behavior?

JustusAdam commented 6 years ago

This Is a duplicate of ohua-dev/alang-clike-parser#1. The feature in question is already implemented. BTW: Perhaps it would have been easier to find that this has already been done if the author of the original issue had provided a proper description 😝

Feliix42 commented 6 years ago

Yeah, well, I'll provide a better description next time. 😄

But this issue is more about the code on line 10, where a tuple is constructed and returned, which produces the following error:

ohuac: Parse error[LParen,UnqualId "old_len",Comma,UnqualId "spliced_str",Comma,UnqualId "new_len",RParen,RBrace]
CallStack (from HasCallStack):
  error, called at .stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Ohua/Compat/Clike/Parser.hs:1067:21 in alang-clike-parser-0.1.0.0-3Foq8Jz79i2PDAwDcu9Zs:Ohua.Compat.Clike.Parser

Is there an error in my code? (Yes I have the current ohuac version, I checked that thrice)

JustusAdam commented 6 years ago

You may have the right ohuac version, but it probably doesn't pull in the latest version of the rust like parser. I did the necessary update for you in 57cfac2974b30dcf987c509210db32c695707ed1. If that fixes it please close this issue.

Feliix42 commented 6 years ago

Works. Thank you! :)