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 support for field interpolation in embeds #11

Closed
TobiasWrigstad opened this issue Jul 18, 2014 · 10 comments
Closed

Add support for field interpolation in embeds #11

TobiasWrigstad opened this issue Jul 18, 2014 · 10 comments

Comments

@TobiasWrigstad
Copy link
Contributor

Currently (AFAIK), reading and writing fields in embed statements is convoluted, for example:

def flag(index : int) : void
  let bs = this.data in 
    embed void
      set((bitset*) #{bs}, #{index})
    end

the local bs variable is needed because #{this.data} is not legal. This is especially convoluted when we want to update a field:

def increment(amount : int) : void 
  let inc = this.value in {
    embed void
      #{inc} = #{inc} + #{amount}
    end;
    this.value = #{inc};
  }

We should allow fields to be used in embed interpolation, e.g., #{this.data} so that the following becomes legal:

def flag(index : int) : void
    embed void
      set((bitset*) #{this.data}, #{index})
    end

respective

def increment(amount : int) : void 
    embed void
      #{this.value} = #{this.value} + #{amount}
    end
@EliasC
Copy link
Contributor

EliasC commented Jul 19, 2014

To me, this is a bit of a luxury issue. Since the benefits are only cosmetic(?) it seems our cycles before the 1st of August would be better spent on other things. Unless of course it's a ten minute fix (@kaeluka?).

@supercooldave
Copy link

Cosmetic speed.

@TobiasWrigstad
Copy link
Contributor Author

This does not need to be fixed before August 1st. Although if it is simple it would be nice -- I do think that cosmetics goes a long way when it comes to showing this to the others and getting them interested, or even using it. This might not be the highest priority, but every little bit helps.

@TobiasWrigstad
Copy link
Contributor Author

@EliasC maybe we could make some milestones here and use that feature to better communicate urgency of things?

@EliasC
Copy link
Contributor

EliasC commented Jul 19, 2014

@TobiasWrigstad Good idea! But the contents of those milestones should be decided IRL rather than early weekend morning messaging =)

@TobiasWrigstad
Copy link
Contributor Author

I agree. I will try to grok how they work and add a "August Meeting" milestone anyway. Seems that one does not block in waiting for "real life."

@kaeluka
Copy link
Contributor

kaeluka commented Jul 19, 2014

This is based on a misunderstanding. You need interpolation ONLY for locals. You can use fields by their one-and-only name. Example:

class Main
  x:int
  def main() : void {
    this.x = 12;
    embed void
      printf("embedded: %lli\n", this->x); //using the field!
    end
  }

This program will output

embedded: 12

Edit: We could add #{this.x} for consistency, but the interpolation would only replace the . with ->. That's pure cosmetics and probably not a good task to work on before the demo

@kaeluka kaeluka closed this as completed Jul 19, 2014
@TobiasWrigstad
Copy link
Contributor Author

That's a bit inconsistent but it will have to do for now!

@supercooldave
Copy link

Embeds are a hack to make progress. If they are too consistent we might start to like them and keep them.

Sent from my iPhone

On 19/07/2014, at 12:19, TobiasWrigstad [email protected] wrote:

That's a bit inconsistent but it will have to do for now!

Reply to this email directly or view it on GitHub.

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

@kaeluka
Copy link
Contributor

kaeluka commented Jul 19, 2014

haha, that's one way to look at it. IMHO, they're dangerously nice already.

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

4 participants