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

EOrust.java:158-160: Implement the "put" method. Now it... #2293

Closed
0pdd opened this issue Jul 21, 2023 · 13 comments
Closed

EOrust.java:158-160: Implement the "put" method. Now it... #2293

0pdd opened this issue Jul 21, 2023 · 13 comments
Assignees
Milestone

Comments

@0pdd
Copy link

0pdd commented Jul 21, 2023

The puzzle 2237-e2051aed from #2237 has to be resolved:

* @todo #2237:45min Implement the "put" method. Now it does
* nothing and created to check rust2java interaction. This
* method relates to building a new eo object in rust insert.

The puzzle was created by @rultor on 21-Jul-23.

Estimate: 45 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@Graur Graur added this to the Urgent milestone Aug 14, 2023
levBagryansky added a commit to levBagryansky/eo that referenced this issue Aug 17, 2023
levBagryansky added a commit to levBagryansky/eo that referenced this issue Aug 18, 2023
levBagryansky added a commit to levBagryansky/eo that referenced this issue Aug 18, 2023
@levBagryansky
Copy link
Member

levBagryansky commented Aug 18, 2023

Consider the example below

[] > rust-put-not-fails
  [content] > book
  QQ.rust > r
    """
    use eo_env::EOEnv;
    use eo_env::eo_enum::EO;
    use eo_env::eo_enum::EO::{EOInt};
    pub fn foo(env: &mut EOEnv) -> EO {
      let v = env.find("^.book") as u32;
      env.put(v, &[0x00, 0x1a, 0xEE]).unwrap();
      EOInt(0 as i64)
    }
    """
    *
      []
  assert-that > @
    book
    $.equal-to
      00-1A-EE

This test is incorrect since book does not have Δ attribute in its declaration

public final class EOω1book extends PhDefault {
  public EOω1book(final Phi sigma) {
    super(sigma);
  }
}

so we cannot put there anything.
@yegor256 please help. Maybe we can make Δ an orbitary attribute for all PhDefault? or put can also take "att" argument like
env.put(v, "content", &[0x00, 0x1a, 0xEE])?

@yegor256
Copy link
Member

yegor256 commented Aug 21, 2023

@levBagryansky it seems that the Rust code is wrong. You need 1) to make a copy of book, 2) make a copy of org.eolang.int, 3) put() a number into int.Δ, and finally 4) attach the copy of int to the copy of book.

@levBagryansky
Copy link
Member

@yegor256 book does not have Δ attribute so should its copy have it?

@yegor256
Copy link
Member

@levBagryansky there are only five objects in EO that have this attribute: int, float, string, bytes and bool. No other objects may have it.

@levBagryansky
Copy link
Member

levBagryansky commented Aug 21, 2023

@yegor256 indeed, so should copy add "φ" attribute? In the example above book does not have it.

@yegor256
Copy link
Member

@levBagryansky What are you trying to achieve? What should be the semantic of this Rust code? How can book be equal to three bytes? :)

@levBagryansky
Copy link
Member

@yegor256 can you please provide an example with put?

@yegor256
Copy link
Member

@levBagryansky I can, if you tell me what you want your program to do? Can you write it in EO, without Rust first?

@levBagryansky
Copy link
Member

levBagryansky commented Aug 21, 2023

@yegor256 In this example r is a copy of book with value inside. Is it legal?

[] > rust-put-not-fails
  [] > book
    10 > price
  QQ.rust > r
    ...
  assert-that > @
    and. > @
      eq.
        r.price
        10
      eq.
        r
        00-1A-EE

@yegor256
Copy link
Member

@levBagryansky this code won't work, since book is not data object and it doesn't decorate one. Also, book is a "closed" object in your example, you can't make a copy of it and then modify price.

@yegor256
Copy link
Member

@maxonfjvipon can you please help?

@levBagryansky
Copy link
Member

levBagryansky commented Aug 21, 2023

@yegor256 @maxonfjvipon is it legal?

[] > rust-put-not-fails
  "qwerty" > book
    10 > price
  QQ.rust > r
    ...
  assert-that > @
    and. > @
      eq.
        r.price
        10
      eq.
        r
        "War and Peace"

@0pdd
Copy link
Author

0pdd commented Aug 23, 2023

The puzzle 2237-e2051aed has disappeared from the source code, that's why I closed this issue.

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