dyne / Zenroom

Embedded no-code VM executing human-like language to manipulate data and process cryptographic operations.
https://dev.zenroom.org
GNU Affero General Public License v3.0
200 stars 64 forks source link

Random statements concerns #979

Open matteo-cristino opened 6 days ago

matteo-cristino commented 6 days ago

My concerns regarding the random statements are as follows:

  1. Use of the object keyword The term "object" is used extensively in the following statements:
    When I create random object of '' bits
    When I create random object of '' bytes
    When I create array of '' random objects
    When I create array of '' random objects of '' bits
    When I create array of '' random objects of '' bytes
    When I pick random object in ''
    When I create random dictionary with '' random objects from ''

    However, "object" usually implies a richer structure, whereas these statements seem to refer to simpler data types like sequences of bits or bytes. This makes the term "object" potentially misleading.

  2. Use of in instead of from in When I pick random object in ''
    • The preposition in is less intuitive here. Using from would better indicate the source of the random selection.
    • Additionally, the pick keyword creates a random_object inside the Zenroom memory. It might be more logical to align this behavior with create to maintain consistency.
  3. Ambiguity in When I create random dictionary with '' random objects from '' This statement can also create an array when picking random elements from an array, which introduces ambiguity.

Proposed changes

Refactoring the first statements to eliminate "object" in favor of more precise terms or a simplified structure:

When I create random '' bits long
When I create random '' bytes long
When I create array of '' random
When I create array of '' random '' bits long
When I create array of '' random '' bytes long

This aligns with the base statement:

When I create random ''

Open question

For the last two statements I am not able to find a correct way to rewrite them because I thought about

When I pickup randomly one element from '' # change 'in' to 'from' and 'pick' to 'pickup' (to follow also `when I pickup from path`)
When I pickup randomly '' elements from '' # total refactor

but where does the random element(s) will be stored?