objeck / objeck-lang

Objeck is a modern object-oriented programming language with functional features tailored for machine learning. It emphasizes expression, simplicity, portability, and scalability. The programming environment consists of a compiler, virtual machine, REPL shell, and command line debugger with IDE plugins.
https://objeck.org
Other
154 stars 11 forks source link

Initialize `Collection.Set` with Delphi range data type #447

Closed ghost closed 7 months ago

ghost commented 8 months ago

https://github.com/objeck/objeck-lang/issues/435

objeck commented 8 months ago

Thank you, I will look into this

objeck commented 8 months ago

Added in a2a464d

ghost commented 8 months ago

Added in a2a464d

What is added? I guess the unordered set that you called SetHash? This issue is about Collection.Range. You got confused by the many issues submitted at the same time by me. I'm sorry. But I'm in a hurry. I know I should spread the questions and the feature requests in a longer time span.

More context:

From the beginning, what I asked is the syntax for Delphi ranges with the operator ... But, from what I know about you, you will refuse to add new syntax to keep the minimalism. So, I switched to request the Collection.Range class. This thread is created before that switch, and still assuming the Delphi ranges syntax. After applying Objeck specific syntax, it's like this:

x := [1..10]; // type inference, x is of type Collection.Range, notice the square brackets, they are added in Objeck to keep the code clean. The original Dephi syntax for ranges doesn't have them. With the brackets, we can apply the rules of Math. For example, [1..10] include 1 and 10, but (1..10) doesn't include 1 and 10, and we can have (1..10] and [1..10), too. I call this the modified Delphi ranges syntax

Initialize Set with the modified Delphi ranges will be like:

x := Collection.Set->New()<Int>;
x := [1..10];

With the switch to Collection.Range without the modified Delphi ranges syntax:

x := Collection.Range->New()<Int>;

x.First := 1;

x.Last := 10;

Initialize Set with Collection.Range will be like:

y := Collection.Set->New()<Int>;

y.fromRange(x);

or maybe simply y := x?

Collection.Range itself is a kind of Set, I think.

Btw, is something like this possible?

x := Collection.Range->New<Int>(1, 10);

I have never seen something like that in Getting Started. The constructor New is always without arguments.

ghost commented 8 months ago

I submitted too many issues. I don't have the time to write it in details like this. I don't know the terminology. So, when you asking me, I don't know how to answer. What I can do is describing, in a lengthy post like this. It is not always possible.

I still think most of the things I proposed are of valid concerns. It's me that is too bad at describing the problems and what I'm wanting, so you failed to understand what I'm talking about and I failed to convince you. Some days in the future, someone better in knowledge than me, will raise the very same problems like I used to, and you will have a much better and productive discussion than you can with me. I'm wasting the issues and discussions threads on your repository.

objeck commented 8 months ago

Added in a2a464d

What is added? I guess the unordered set that you called SetHash? This issue is about Collection.Range. You got confused by the many issues submitted at the same time by me. I'm sorry. But I'm in a hurry. I know I should spread the questions and the feature requests in a longer time span.

More context:

From the beginning, what I asked is the syntax for Delphi ranges with the operator ... But, from what I know about you, you will refuse to add new syntax to keep the minimalism. So, I switched to request the Collection.Range class. This thread is created before that switch, and still assuming the Delphi ranges syntax. After applying Objeck specific syntax, it's like this:

x := [1..10]; // type inference, x is of type Collection.Range, notice the square brackets, they are added in Objeck to keep the code clean. The original Dephi syntax for ranges doesn't have them. With the brackets, we can apply the rules of Math. For example, [1..10] include 1 and 10, but (1..10) doesn't include 1 and 10, and we can have (1..10] and [1..10), too. I call this the modified Delphi ranges syntax

Initialize Set with the modified Delphi ranges will be like:

x := Collection.Set->New()<Int>;
x := [1..10];

With the switch to Collection.Range without the modified Delphi ranges syntax:

x := Collection.Range->New()<Int>;

x.First := 1;

x.Last := 10;

Initialize Set with Collection.Range will be like:

y := Collection.Set->New()<Int>;

y.fromRange(x);

or maybe simply y := x?

Collection.Range itself is a kind of Set, I think.

Btw, is something like this possible?

x := Collection.Range->New<Int>(1, 10);

I have never seen something like that in Getting Started. The constructor New is always without arguments.

Thanks for the detailed feedback. I looked at the Python and Delphi range() functions and plan to add this to the next release.

objeck commented 7 months ago

The range classes have been implemented; however, the syntax varies from the above. For example, the start, end, or step values for a Range class must be passed into one of the constructors. There are also methods to set the start, end, or step values.

https://github.com/objeck/objeck-lang/blob/master/programs/tests/prgm277.obs

ghost commented 7 months ago

Next time please use permalink. A lot of sample codes you gave me in the past were lost due to this. That file constantly changing.

https://github.com/objeck/objeck-lang/blob/0bf08d27cb082e5279397cc65439c3426888c4b0/programs/tests/prgm277.obs

Btw, thank you.

objeck commented 7 months ago

Yes, has changed from testing.