albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
913 stars 156 forks source link

The next version of squirrel,Can you add integrated binding to C + + 20 ranges syntax? #246

Open D22699 opened 2 years ago

D22699 commented 2 years ago

Squirrel is very easy to use~~~

Thanks for the development of @albertodemichelis ! Only after version 3.1 was updated in 2016, there was no news again?

Recently, the new features of C + + 23 standard have been added a lot? Ranges has the most features, and ranges has become the biggest winner. Our question is, can we integrate and bind the ranges syntax above C + + 20 in squirrel? Because it's so convenient to write business code with ranges!

Ranges realizes a variety of parallel combined filtering operations and other operations through pipeline symbols, which should also be the core functional goal of the next generation of squirrel. It not only saves a lot of code, but also greatly increases the flexibility of the algorithm!

In addition, can squirrel support the isolation of multi sub table data and operations? We hope that on the basis of the root table, there can be completely independent sub tables, which can support the same name of objects, and the algorithm can be limited to a certain sub table. C + + 20 provides modules, realizes a high degree of isolation, and even isolates Hongdu? Is there a similar feature in JS? For example, if we declare in the root table and instantiate in different sub tables, the algorithm and object will not be afraid of the problem of duplicate names, and the data will be effectively isolated? In this way, it is convenient to write a large amount of business code.

We are highly optimistic about squirrel and hope @albertodemichelis can give an answer!

thank! thank! thank!

zeromus commented 2 years ago

I unpacked all the questions from this, while trying to understand it

  1. can the squirrel .h API include "ranges" style code from c++ standards from the future... for... what exactly? iterating over table elements? Not likely, since squirrel doesn't even really offer anything from c++ standards from the past
  2. can squirrel support "multi sub table data". I guess this means multiple inheritance?
  3. asking about whether JS has something like C++ "modules", but for some reason using the "sub tables" terminology and sounding like the exact same question. I presume once it's established that JS has something like c++ "modules", the follow-up would be can squirrel have it too?
  4. I doubt anyone knows what "hongdu isolation" means but I am going to guess it's something like a vow of abstinence for a period which clears your mind and helps you write cleaner code

And all the same questions were asked in another thread, where it should be deleted.

rversteegen commented 2 years ago

The post has clearly been run through a translator so is hard to understand. Since "ranges syntax" was mentioned, I think the request is for the ability to write a compound function call using pipe operators, e.g. (stealing an example from elsewhere) vec | foo | bar(3) | baz(7) is equivalent to baz(bar(foo(vec), 3), 7). In C++ that's accomplished with operator overloading and template gobbledygoo but in a scripting language it could be builtin syntax, preferably not overloading |.

But is there really much benefit to that syntax?

D22699 commented 2 years ago

sense @rversteegen @zeromus

The point is C++ 20 "ranges",squirrel won't support "ranges",But can you provide an indirect binding method?

“range = vec | foo | bar(3) | baz(7) | baz(bar(foo(vec), 3), 7)”

Hopefully, squirrel supports "ranges" and it will be more convenient to write business code.

rversteegen commented 2 years ago

Oh, if you want a way to create a binding to a C++ range, then I think that doesn't require any changes to Squirrel, it can just be a library which creates a proxy object (a userdata?). Maybe.