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

Does EO allow null values? #3545

Closed
volodya-lombrozo opened this issue Nov 25, 2024 · 18 comments
Closed

Does EO allow null values? #3545

volodya-lombrozo opened this issue Nov 25, 2024 · 18 comments
Labels

Comments

@volodya-lombrozo
Copy link
Member

I thought, that EO doesn't use null objects, references or values. I read it from this README excerpt:

... we don't tolerate:
...
NULL (why?)

However, from this comment I can see, that EO actually can define some mysterious "empty" bytes which are null values actually:

empty bytes must look like --

It seems, we need to fix the README and say the truth.

@volodya-lombrozo
Copy link
Member Author

@yegor256 Could you help here, please?

@yegor256
Copy link
Member

@volodya-lombrozo the "empty bytes" is not null. Instead, it's similar to new byte[0] in Java

@volodya-lombrozo
Copy link
Member Author

volodya-lombrozo commented Nov 25, 2024

@yegor256 What's the difference with 00- value then? and with 00?

@yegor256
Copy link
Member

yegor256 commented Nov 25, 2024

@volodya-lombrozo even though we claim that "we don't have NULL", there is something that people may consider to be NULL in EO. We can do this, in EO (pseudo-code):

// create an object with the "k" attribute, not yet attached to any object
a = [ k: ∅ ]   

// create a copy of "a", attaching "42" to the "k" attribute
b = a(k -> 42)

Here, we can think that k is attached to NULL, but the semantic is different. How? In EO, unlike all other language that have NULL, it's impossible to re-attach k. Thus, it's not NULL, but a placeholder for an object.

@yegor256
Copy link
Member

yegor256 commented Nov 25, 2024

@volodya-lombrozo here, 00- means new byte[1] {0x00} (one byte), while -- means new byte[0] (no bytes). You can do:

--.length   // this is zero

@volodya-lombrozo
Copy link
Member Author

@yegor256 However, if I try to access a.k attribute I will get some sort of NPE, isn't it?

@volodya-lombrozo even though we claim that "we don't have NULL", there is something that people may consider to be NULL in EO. We can do this, in EO (pseudo-code):

// create an object with the "k" attribute, not yet attached to any object
a = [ k: ∅ ]   

// create a copy of "a", attaching "42" to the "k" attribute
b = a(k -> 42)

Here, we can think that k is attached to NULL, but the semantic is different. How? In EO, unlike all other language that have NULL, it's impossible to re-attach k. Thus, it's not NULL, but a placeholder for an object.

@yegor256
Copy link
Member

@volodya-lombrozo indeed, if you do a.k, you will get a runtime error

@volodya-lombrozo
Copy link
Member Author

@volodya-lombrozo here, 00- means new byte[1] {0x00} (one byte), while -- means new byte[0] (no bytes). You can do:

--.length   // this is zero

@yegor256 What about just 00, can I save it to org.eolang.bytes ?

@yegor256
Copy link
Member

@volodya-lombrozo if you say 00 in EO, it will mean instance of 8-bytes org.eolang.number. If you need org.eolang.bytes with a single byte inside, you have to say 00-

@volodya-lombrozo
Copy link
Member Author

volodya-lombrozo commented Nov 25, 2024

@volodya-lombrozo if you say 00 in EO, it will mean instance of 8-bytes org.eolang.number. If you need org.eolang.bytes with a single byte inside, you have to say 00-

@yegor256 I guess it's related to this issue more #3546. I don't use org.eolang.number

@yegor256
Copy link
Member

@volodya-lombrozo did I answer the original question? Or still not clear why NULL is here?)

@volodya-lombrozo
Copy link
Member Author

@yegor256 You answered, yes, thank you! Actually -- is not a null value, it's new byte[0]. Although, I'm wondering where we might need such objects, it more or less clear.

However, as for NULL values, we actually have them. You call these values as attributes that "not yet attached to any object".

Maybe we can mention these important findings somewhere in the README? What do you think?

@yegor256
Copy link
Member

@volodya-lombrozo we can write a blog post about it: objectionary/news.eolang.org#74

@volodya-lombrozo
Copy link
Member Author

volodya-lombrozo commented Nov 25, 2024

@yegor256 Blog posts are just news. We need a proper reliable documentation.

@yegor256
Copy link
Member

@volodya-lombrozo we don't have "language manual" so far, we use blog posts instead, while the language is in active development

@volodya-lombrozo
Copy link
Member Author

@yegor256 Even if it's in active development, it's better to have some document to rely on. Otherwise, it makes the development of tools related to the language extremely hard. Blog posts do not solve the problem—they aren't reliable.

To put it another way, just as an analogy: If I want to make people use my imaginary "server," I need to provide an API for them. Otherwise, how will they know about the endpoints and in what format to make HTTP requests? The same applies here. Of course, we can say that we are in "development," but that means we block the development of tools around the language.

@yegor256
Copy link
Member

@volodya-lombrozo I can move this ticket to this repo: https://github.com/objectionary/eo-book Eventually, we will put this information into the book. How does this sound?

@volodya-lombrozo
Copy link
Member Author

@yegor256 a bit better. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants