fleabitdev / glsp

The GameLisp scripting language
https://gamelisp.rs/
Apache License 2.0
395 stars 13 forks source link

Call for suggestions: a new name for method clauses #6

Closed fleabitdev closed 4 years ago

fleabitdev commented 4 years ago

The alternative meaning of the word meth can be distracting. It might also cause trouble with web filters. I think I'd like to change it.

My working plan is to simply replace meth with met:

(defstruct Rect
  x y w h

  (met area ()
    (* @w @h)))

(let rect (Rect:new 0 0 10 10))
(prn (has-met? rect 'area))
(call-met 'area rect)

This issue is open for suggestions for alternative names. Some things to bear in mind:

usaccounts commented 4 years ago

defm func method mth If verbosity is an issue not sure why defn|defmacro|defclass need de/def in the front.

Grinshpon commented 4 years ago

If verbosity is an issue not sure why defn|defmacro|defclass need de/def in the front.

I think defm or method are good and I agree with @usaccounts on this point

fleabitdev commented 4 years ago

Thanks for the suggestions!

Unlike Rust, GameLisp is too dynamic to detect global definitions automatically. To use Rust's terminology, there's no way to differentiate an "item" from an "expression".

This is the reason for GameLisp's current (rough) naming convention:

We could potentially shuffle these names around to make-thing, thing and let-thing respectively, but it would introduce several local inconsistencies (I'm not sure how I'd rename the current def, fn and macro forms) while also being inconsistent with other Lisps.

The inconsistent formatting between defthing and let-thing does bother me, so I'm happy to take suggestions for alternatives.

I definitely don't want to use def or let within class definitions, because class members are neither global nor local variables.

I'll give method a try and see what it feels like, but for something which is as fundamental and common as fn, those extra three characters (compared to met) would be a genuine downside.

lerouxrgd commented 4 years ago

mfn ? Which could be read as method function or member function.

cedric-h commented 4 years ago

Personally I prefer met the most.

fleabitdev commented 4 years ago

Thanks for everyone's suggestions! I decided on met, and implemented the change in 21ccaf0.

I haven't managed to think up a good replacement for field or const, so I'll leave them as they are for now.