atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.91k stars 415 forks source link

Always bind `*browser*` #2670

Open Ambrevar opened 2 years ago

Ambrevar commented 2 years ago

In https://github.com/atlas-engineer/nyxt/pull/2666#discussion_r1031497582 we discussed the problem of having to protect against NIL *browser* all over the place. Then having to extract some default value, which duplicates it since it's already in the slot initforms.

Suggestion: always bind *browser* to at least (make-instance 'browser).

I believe this should do the right thing. Thoughts?

aadcg commented 2 years ago

Agreed.

aadcg commented 1 year ago

Sorry for bikesheding this topic, but are there cases when we really must use *browser*?

There are cases when we call it, but we should define a method in the browser class. For instance, see buffer-list, buffers-get, buffers-set or buffers-delete.

Ambrevar commented 1 year ago

Sorry I didn't understand. Can you rephrase / give an example?

aadcg commented 1 year ago

I'm saying that some calls to *browser* are clearly not needed. For instance, look at buffer-list. I think it should be a method of the browser class.

Ambrevar commented 1 year ago

If it's a method, then the problem is only moved somewhere else: buffer-list will be called with (buffer-list *browser*) and if *browser* is NIL, an error is raised.