Permalink
Browse files

README: One might as well perform in-place reverse directly

  • Loading branch information...
Mon-Ouie committed Mar 27, 2013
1 parent 110220c commit 0b25bc5be3b9099b233a8be66c60812e63de89b7
Showing with 1 addition and 1 deletion.
  1. +1 −1 README.md
View
@@ -40,7 +40,7 @@ Here's how to create a simple REPL with live syntax highlighting and tab complet
# Alt-R should reverse the line, because we like to look at our code in the mirror
c.bind "\er" do |cool|
cool.replace_line cool.line.reverse
cool.line.reverse!
end
end

3 comments on commit 0b25bc5

@epitron

This comment has been minimized.

Show comment
Hide comment
@epitron

epitron Mar 27, 2013

Contributor

Oh man, I just realized that replace_line is going to cause weird problems since it doesn't #dup the string either.

I think it would be good if Coolline had a #line= method which automatically: dups the argument, sets @pos, and re-renders the readline.

It would be handy in the #readline method's initialization even. This:

    @line        = default_line.dup
    @pos         = @line.size
    @accumulator = nil

    @history_moved = false

    @should_exit = false

    render

...could be changed to:

    @accumulator = nil
    @history_moved = false
    @should_exit = false

    self.line = default_line
Contributor

epitron replied Mar 27, 2013

Oh man, I just realized that replace_line is going to cause weird problems since it doesn't #dup the string either.

I think it would be good if Coolline had a #line= method which automatically: dups the argument, sets @pos, and re-renders the readline.

It would be handy in the #readline method's initialization even. This:

    @line        = default_line.dup
    @pos         = @line.size
    @accumulator = nil

    @history_moved = false

    @should_exit = false

    render

...could be changed to:

    @accumulator = nil
    @history_moved = false
    @should_exit = false

    self.line = default_line
@Mon-Ouie

This comment has been minimized.

Show comment
Hide comment
@Mon-Ouie

Mon-Ouie Mar 27, 2013

Owner

I think this might be related to why I didn't have it in the first place: one can use cool.line.replace … which takes care of avoiding the shared copy.

Owner

Mon-Ouie replied Mar 27, 2013

I think this might be related to why I didn't have it in the first place: one can use cool.line.replace … which takes care of avoiding the shared copy.

@epitron

This comment has been minimized.

Show comment
Hide comment
@epitron

epitron Mar 28, 2013

Contributor

That doesn't update the position though. You could end up with a cursor floating in null space, past the edge of the string universe! :)

Contributor

epitron replied Mar 28, 2013

That doesn't update the position though. You could end up with a cursor floating in null space, past the edge of the string universe! :)

Please sign in to comment.