-
Notifications
You must be signed in to change notification settings - Fork 121
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 native map traversing functionality #106
Conversation
I've ran into a little problem when was trying to implement it. Here's an example of how to traverse a map in FunC:
This loop uses 3 variables: key, value and flag that indicates whether the loop should be terminated or not (actually it's set to Well, we can just ban nested map traversing loops... but I don't think it's a good idea. @anton-trunov what do you think? |
This comment was marked as abuse.
This comment was marked as abuse.
@xsr I've thought about this, but it adds some kind of indeterminacy to compiler which isn't good. |
Maybe can it be solved by checking key instead of flag (key.is_null?)? |
@nonam3e Well, it’ll work, but will consume more gas (18 for each iteration). |
Found an interesting read on designing a |
@Gusarich The usual approach here is to define a fresh identifier generator. Something like this: // fresh.ts
let counter = 0; // a mutable variable
function freshIdentifier(prefix: string): string {
const fresh = `__tact_freshId${prefix}${counter}`;
counter += 1;
return fresh;
} and then you can use it to generate fresh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HUGE!
WORKS ON MY macOS MACHINE
This PR introduces the
for
loop - currently just the map traversing version of it, but I'm also thinking about implementing general purposefor
loops in future.Syntax (may be changed, it's up for discussions):
What have been already done:
What have to be done: