laurent.orseau
2020-3-10 07:01:12

@spdegabrielle they also had assoc lists ;)


laurent.orseau
2020-3-10 07:08:39

@robby What about enriching the lexers with a function get-sub-type that by default just returns the type, but could be overloaded in racket to check characters and return 'line-comment for example?


laurent.orseau
2020-3-10 08:23:28

I’m thinking: Each lexer module requires "lexer-base.rkt" which contains a dict, and each lexer registers in this dict a function get-sub-type (or something) that does what’s described above. The module-lexer is a little special and would need to update this function depending on the raw-lexer.

The bonus is that this dict would then be extensible, so would allow for future augments of the interface.

I’m open to criticisms and suggestions of course. I’m just trying to find a way to solve this issue.


spdegabrielle
2020-3-10 11:17:41

@laurent.orseau I was thinking of hash tables


robby
2020-3-10 11:24:05

@laurent.orseau I still don’t understand the problem. Why do you need the lexer to tell you the difference between line comments and bracketed comments? In reply to earlier comments, yes to your bullet 1. That’s what I In reply to your bullet 2. I don’t yet understand why you need this information. As for 3. I think I need more help to understand why you are making these changes and why the current situation isn’t working.


laurent.orseau
2020-3-10 11:24:51

Ok, let me reboot then


robby
2020-3-10 11:24:59

If you are still fixing the automatic comments thing, I don’ tunderstand why you don’t just ask the colorer whether or not the character is a comment.


robby
2020-3-10 11:29:22

(you may have to insert and then remove it)


laurent.orseau
2020-3-10 11:32:47

Consider this case, where @ indicates the position of the cursor (define (get-dict) '((a . b) (c . d) (e . f) ; blah blah (blah @ )) The colorer classifies this position as 'white-space because the next character is #\newline. Thus if you press ), smart-skip skips to the next paren.

You could instead check the previous position, which would be inside the comment, but then that breaks this case: (define (get-dict) '((a . b) (c . d) (e . f) #\|blah blah\|#@ )) where here skipping is the right behaviour, but the colorer returns the same information as in the previous case, so we can’t differentiate the two cases.


robby
2020-3-10 11:33:21

Yes, the colorer only colors what’s there


robby
2020-3-10 11:33:29

So if you want to know what color something would be, you have to insert it


robby
2020-3-10 11:33:38

At least, I think that’s how things are supposed to work!


laurent.orseau
2020-3-10 11:34:01

But smart-skip precisely prevents this insertion


laurent.orseau
2020-3-10 11:34:56

So you say: insert ( when typed, look at the color, erase it, then skip it if it is indeed a comment? That sounds rather suboptimal, no?


laurent.orseau
2020-3-10 11:36:33

That would trigger a whole lexing/coloring phase just for checking whether we are inside a comment… when the lexer should already know that :confused:


robby
2020-3-10 11:36:42

It sounds a lot less suboptimal than changing the lexer interface


robby
2020-3-10 11:36:50

changing the lexer interface sounds extremely horrible.


robby
2020-3-10 11:37:05

I dont’ think inserting it and checking on it is that bad.


robby
2020-3-10 11:37:11

(that bad overall, I mean)


robby
2020-3-10 11:37:27

What concretely is the problem? I can see how you wouldn’t like the way the code looks, but are there other problems?


laurent.orseau
2020-3-10 11:38:04

Efficiency. DrRacket already has issues in this space, I don’t want to make it worse just for a paren


robby
2020-3-10 11:41:39

I have to ask: have you measured anything?


laurent.orseau
2020-3-10 11:41:46

Plus, really, if it’s racket code, I just need to check whether the character at the beginning of the comment is ; . This is all I need, but I just need to know whether it’s racket code or something else


robby
2020-3-10 11:41:59

That’s not how drracket works.


robby
2020-3-10 11:42:10

From DrRacket’s perspective “it is just racket code” isn’t the right way to think about it


robby
2020-3-10 11:42:21

DrRacket asks the language “what kind of thing is this?” and the language says


laurent.orseau
2020-3-10 11:42:28

I understand that now, hence my proposal for a more general approach


robby
2020-3-10 11:42:30

It might be #lang scribble or racket or whatever


robby
2020-3-10 11:42:46

You have cited efficiency as a concern


robby
2020-3-10 11:42:51

but you haven’t shown anytthing that’s slow


robby
2020-3-10 11:43:01

Please do that first.


laurent.orseau
2020-3-10 11:43:14

You mean for the case at hand or in general?


robby
2020-3-10 11:43:14

I want to be very clear here:


robby
2020-3-10 11:43:24

changing the lexer interface is a huge undertaking


robby
2020-3-10 11:43:32

We do not even know the number of people that have code that depend on it.


robby
2020-3-10 11:43:46

And the ones that we do know are non trivial to change


robby
2020-3-10 11:43:54

Further more, there are serious concerns with the proposed API


robby
2020-3-10 11:44:12

We need to keep the interface simple and work with the information it gives us


laurent.orseau
2020-3-10 11:44:16

I was planning on making it completely backward compat., just augmenting it. What exists should work just as fine.


laurent.orseau
2020-3-10 11:44:28

But I understand the need for simplicity too


robby
2020-3-10 11:44:28

or else we are pushing too much work into the language implementation when it can be done once and for all inside drracket


robby
2020-3-10 11:45:28

Your suggestion above is not backwards compatible unless you count “does not work with the new feature” as backwards compatible. While I agree that one could think that way, I would prefer to make things work without having to change every language and I don’t see that extending the interface has that property.


robby
2020-3-10 11:46:36

re: efficiency:


laurent.orseau
2020-3-10 11:46:44

I would prefer that too, but the fix you propose is also DrRacket specific, no?


robby
2020-3-10 11:46:56

Hm.


robby
2020-3-10 11:47:01

I thought we were talking about DrRacket?


laurent.orseau
2020-3-10 11:47:02

At least I give the mean to do it right for other people using the colorer and lexers elsewhere


robby
2020-3-10 11:47:33

Okay, lets talk more about this later on. I’ll come back and read your comments more but I can’t do this online talking thing for so long anymore.


laurent.orseau
2020-3-10 11:48:01

sure


robby
2020-3-10 11:48:59

sorry to be a downer


laurent.orseau
2020-3-10 11:48:59

In any case, I’m still looking for whatever is best, and that you’re happy with. I’ll give insert/delete a shot (but it badly hurts my intuition :stuck_out_tongue: )


laurent.orseau
2020-3-10 11:49:25

(at least it’s a solution nonetheless)


laurent.orseau
2020-3-10 12:15:04
  1. The culprit code is in framework/private/racket.rkt here: https://github.com/racket/gui/blob/master/gui-lib/framework/private/racket.rkt#L517 so any change to this code would be racket-specific anyway

  2. I just discovered that the code in racket.rkt already checks for the type of comment in an ad-hoc way, for example here: https://github.com/racket/gui/blob/master/gui-lib/framework/private/racket.rkt#L1656

In light of this, I think my first proposal was fine: https://racket.slack.com/archives/C8FS3SS22/p1583743470019900


robby
2020-3-10 12:54:23

Thank you, @laurent.orseau! I do agree that there are possible performance issues here (especially when you need to wait for the colorer) but I think that we need to fix those instead of making the interface more complex. It is less work overall is my guess. As for the file named “racket.rkt” that is a flaw in the name of the file. It isn’t (supposed to be) racket-specific. I agree that insert-brace-pair is problematic.


robby
2020-3-10 12:54:42

But I do agree that this is not making the status quo substantially worse than it already is.


robby
2020-3-10 12:54:45

Thanks for pointing that out!


robby
2020-3-10 12:55:10

If you were to make a pull request for this, perhaps putting the results of this discussion into a comment near the undesireable code would be great


laurent.orseau
2020-3-10 13:15:48

Thanks Robby, okay I’ll do that then.