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

! symbol in EO grammar should be syntax sugar for dataized object #3042

Closed
maxonfjvipon opened this issue Apr 3, 2024 · 4 comments · Fixed by #3079
Closed

! symbol in EO grammar should be syntax sugar for dataized object #3042

maxonfjvipon opened this issue Apr 3, 2024 · 4 comments · Fixed by #3079

Comments

@maxonfjvipon
Copy link
Member

maxonfjvipon commented Apr 3, 2024

You can find Here what ! symbol does in EO.
We also have similar logic in dataized object which also dataizes given object and starts behave as bytes.
So it's seems that ! should be syntax sugar for some dataized decorator object. Then this "caching" will become more clear.

The task may be done in two steps:

  1. Implement object dataized and write some tests for it
  2. Implement XSL transformations that replace ! with dataized application: x! -> dataized x
Copy link

github-actions bot commented Apr 3, 2024

@maxonfjvipon thanks for the report, but here some unclear moments:

  • The bug report lacks a clear, concise summary of the problem at the beginning. The first line should be a brief summary of the issue. The author can improve this by providing a one-sentence summary of the problem at the start of the report.
  • The bug report does not include any information about the environment in which the bug was found (e.g., software version, operating system). The author can improve this by including details about the environment.
  • The bug report does not include steps to reproduce the bug. The author can improve this by providing a step-by-step guide on how to reproduce the issue.

Please fix the bug report in order it to get resolved faster.
Analyzed with gpt-4

@maxonfjvipon
Copy link
Member Author

Here's possible implementation:

[object] > const
  memory.alloc object > @

But it does not seem to work:

# Test.
[] > const-does-not-do-recalculation
  memory.alloc 0 > m
  # Object.
  [] > obj
    ^.m.write (^.m.as-int.plus 1) > @
  const obj > cached
  seq > @
    *
      cached
      cached
      !.eq m

Here:

seq > @
  *
    cached
    cached

when we do cached we actually do $.cached which actually makes copy of original cached. This copying leads to copying of const.@ so writing to m executes twice

maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 4, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 4, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 4, 2024
@maxonfjvipon maxonfjvipon changed the title ! symbol in EO grammar should be syntax sugar for const object ! symbol in EO grammar should be syntax sugar for dataized object Apr 10, 2024
@maxonfjvipon
Copy link
Member Author

const object was removed, now we have dataized(#3066) which should be used

@maxonfjvipon
Copy link
Member Author

@yegor256 we have an interesting case here. Imagine this abstract object which we want to cache

1.[y] > obj
2.  [] > x!
3.     ^.y > @
4.  $.x > @

When we're at line 4 we do $.x -> x is taken, copied, its \rho is set to $(obj), then at line 3 we do ^.y -> $.y -> obj.y and everything works fine

But if we replace ! the code would look like:

1.[y] > obj
2.  as-bytes. > x
3.    dataized 
4.      []
5.        ^.x > @
6.  $.x > @

Now abstract object at the line 4 will never have \rho (because it's nameless) and object at the line 5 won't work.
The only idea I see for now is to give this abstract object some synthetic name:

1.[y] > obj
2.  as-bytes. > x
3.    dataized 
4.      [] > synthetic
5.        ^.x > @
6.  $.x > @

Then it should work. WDYT?

maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
maxonfjvipon added a commit to maxonfjvipon/eo that referenced this issue Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant