backspaces / agentscript

An Agent Based Modeling system (ABM)
http://backspaces.github.io/agentscript/
GNU General Public License v3.0
106 stars 14 forks source link

don't allow override of turtle id #78

Open m0ose opened 1 year ago

m0ose commented 1 year ago

It turns out that it turtle list is sorted by id, and if you set the id it will mess some internal things, like turtle removal.

Maybe the turtle id should be private, or have a setter that gives you a warning to avoid shooting yourself in the foot?

backspaces commented 1 year ago

I agree! "Private", as per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields ..looks pretty useful. Have you tried it?

I'm surprised that all the browsers support it, and so quickly.

m0ose commented 1 year ago

I haven't used the private class fields. It looks well supported, https://caniuse.com/mdn-javascript_classes_private_class_fields

backspaces commented 1 year ago

This is more difficult than it seemed. Turns out use of private variables is class based but AS makes heavy use of prototypal methods. So this basically depends on: https://github.com/backspaces/agentscript/issues/83

m0ose commented 1 year ago

Could it be renamed to something less common like id ?

On Wed, Oct 4, 2023, 9:53 AM Owen Densmore @.***> wrote:

This is more difficult than it seemed. Turns out use of private variables is class based but AS makes heavy use of prototypal methods. So this basically depends on: #83 https://github.com/backspaces/agentscript/issues/83

— Reply to this email directly, view it on GitHub https://github.com/backspaces/agentscript/issues/78#issuecomment-1747193848, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADADQRUJODL37PYQY553XLX5WBA3AVCNFSM6AAAAAA4DOQXQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBXGE4TGOBUHA . You are receiving this because you authored the thread.Message ID: @.***>