Le dimanche 15 mai 2016 à 08:08 -0700, Ford Ox a écrit :
> Thanks Yu and Quinn.
> 
> Now lets go one step further. Lets say I don't want to use any
> default parse function. I will make my own.
> 
> type Buffer{T} x::T end
> 
> function store!(b::Buffer{String}, c::Char) b.x = "$(b.x)$x" end
> function store!(b::Buffer{Int}, c::Char, d::Int) b.x += (c -
> '0')*10^d end #d is number of digits
> 
> 
> Usage
> get_rid_of_leading_spaces()
> while !isspace((x = read_next_char()) store(buffer, x) end
> 
> But I can see potential problems:
> "$(b.x)$x" is probably not much effective, maybe I should use arrays
> of chars with fixed size, but how do I convert it to string?
> string(char_array...) doesn't work with '\0' and I don't want to
> create new array by calling char_array[1:size].
> is b.x += (c - '0')*10^d really the fastest implementation possible?
See IOBuffer and takebuf_string.


Regards

> As a side note, is there anything like show_method_body(function)? I
> often want to see how is function base.xy implemented, but I have to
> manually search all the files which is quite exhausting.
> 
>   

Reply via email to