<Pongles>
Radar, sorry to bug you again, but do you know if there is a way to flush data sent to the server without blocking?
mrconfused has quit [Ping timeout: 268 seconds]
BSaboia has joined #ruby
milardovich has joined #ruby
brent__ has quit [Remote host closed the connection]
brent__ has joined #ruby
gothicsouth has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
nobitanobi has joined #ruby
nadir has quit [Quit: Connection closed for inactivity]
<Pongles>
I am trying to mimic a telnet server but I don't know a good way to grab the negotiation at the start
nobitanobi has quit [Ping timeout: 240 seconds]
sagax has quit [Ping timeout: 240 seconds]
LastWhisper____ has joined #ruby
<Radar>
Pongles: no sorry I don't know that
cisco has quit [Quit: Leaving.]
mrconfused has joined #ruby
rgr has quit [Ping timeout: 245 seconds]
olivi____ has quit [Remote host closed the connection]
oliv_____ has joined #ruby
ResidentBiscuit has joined #ruby
oliv_____ has quit [Remote host closed the connection]
olivi____ has joined #ruby
mrconfused has quit [Ping timeout: 245 seconds]
Fernando-Basso has quit [Quit: WeeChat 1.8]
charliesome has joined #ruby
ResidentBiscuit has quit [Ping timeout: 240 seconds]
olivi____ has quit [Remote host closed the connection]
brent__ has quit [Remote host closed the connection]
mrconfused has joined #ruby
cam27 has quit [Quit: cam27]
im0nde has quit [Ping timeout: 240 seconds]
nadir has joined #ruby
sneakerhax has joined #ruby
claw has quit [Read error: Connection reset by peer]
claw has joined #ruby
oliv_____ has joined #ruby
apparition has joined #ruby
jameser has joined #ruby
brent__ has joined #ruby
chopin has joined #ruby
HumbleBee has quit [Quit: Leaving]
alveric3 has quit [Ping timeout: 240 seconds]
eightlimbed has quit [Ping timeout: 240 seconds]
alveric3 has joined #ruby
knamehost has joined #ruby
eightlimbed has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
erlend has quit [Quit: Bye]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
SenpaiSilver_ has quit [Quit: Leaving]
PorcoRex has joined #ruby
<PorcoRex>
Good evening.
brent__ has quit [Remote host closed the connection]
bruce_lee has quit [Read error: Connection reset by peer]
erlend has joined #ruby
<knamehost>
hi . where ca i find a good read about ruby ... tuts vids etc
<PorcoRex>
knamehost, there are several good resources. Are you a developer already? A beginner?
HoierM has joined #ruby
demio has joined #ruby
chopin has quit []
Gues_____ has joined #ruby
<knamehost>
PorcoRex, beginner my friend
5EXAA2YP3 has joined #ruby
5EXAA2YP3 has quit [Client Quit]
<knamehost>
im going to deve too as well
jusa has joined #ruby
Gues_____ has quit [Client Quit]
charliesome has joined #ruby
Gues_____ has joined #ruby
<PorcoRex>
knamehost, this is probably a nice one to step your toe: http://poignant.guide/
jusa has quit [Ping timeout: 240 seconds]
zacts has quit [Quit: WeeChat 1.8]
<knamehost>
ty PorcoRex
<PorcoRex>
knamehost, sure, enjoy.
lel- is now known as lel
d^sh has quit [Ping timeout: 245 seconds]
jakew has joined #ruby
d^sh has joined #ruby
jakew has quit [Client Quit]
Uranio has joined #ruby
jrafanie has joined #ruby
jameser has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
ResidentBiscuit has joined #ruby
<Arahael>
Curious how ruby has both ==, and ===, if == already compares object identity.
mrconfused has quit [Ping timeout: 245 seconds]
<PorcoRex>
Arahael, === is case equality. The operator can be overridden to give "better" matches, generally (and, in my opinion, preferably) on case statements.
Uranio has left #ruby ["while you read this, a kitty dies"]
<Arahael>
PorcoRex: It's just a curiousity compared to say, javascript.
kies has quit [Ping timeout: 240 seconds]
<Arahael>
PorcoRex: "==" there is 'somewhat equal', whereas '===' makes it more likely that the types themselves are equal as well
<PorcoRex>
Arahael, it's completely different from JS in that sense. Not even close.
<Arahael>
PorcoRex: Indeed. Not neccessarily a bad thing - the javascript situation is horrible.
<elomatreb>
You generally don't use === yourself, ever
<Arahael>
elomatreb: Good to know. (In ruby)
mrconfused has joined #ruby
nertzy has quit [Quit: This computer has gone to sleep]
<Radar>
Then there's the fabled ====
<PorcoRex>
Radar, seriously? I just read it was reserved for future use.
<Arahael>
Radar: I thought that was only for the haskell devs? ;)
demio has quit [Quit: Computer has gone to sleep.]
demio has joined #ruby
demio has quit [Client Quit]
GodFather has quit [Quit: Ex-Chat]
GodFather has joined #ruby
kies has joined #ruby
genpaku has quit [Remote host closed the connection]
AndBobsYourUncle has joined #ruby
AndBobsYourUncle has quit [Client Quit]
mrconfused has quit [Ping timeout: 245 seconds]
arescorpio has joined #ruby
genpaku has joined #ruby
GodFather has quit [Ping timeout: 240 seconds]
ResidentBiscuit has quit []
belmoussaoui has joined #ruby
belmoussaoui has quit [Remote host closed the connection]
<eightlimbed>
can someone explain how this determines whether a number is prime or not?
<eightlimbed>
(2..n/2).none? { |i| n % i == 0}
cyphase has quit [Ping timeout: 260 seconds]
<eightlimbed>
why it is n/2 and not n-1
<elomatreb>
A number larger than the half of n trivially can't divide it evenly
belmoussaoui has joined #ruby
roamingdog has joined #ruby
jgpawletko has joined #ruby
cyphase has joined #ruby
jgpawletko has quit [Client Quit]
roamingdog has quit [Remote host closed the connection]
roamingdog has joined #ruby
Uranio-235 has joined #ruby
Uranio-235 has quit [Client Quit]
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mrconfused has joined #ruby
pb122 has joined #ruby
jusa has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
HoierM has quit [Ping timeout: 245 seconds]
charliesome has joined #ruby
milardovich has quit [Read error: Connection reset by peer]
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
charliesome has joined #ruby
eightlimbed has quit [Ping timeout: 240 seconds]
mrconfused has quit [Ping timeout: 245 seconds]
jusa has quit [Ping timeout: 260 seconds]
mrconfused has joined #ruby
quazimodo has joined #ruby
_sfiguser has quit [Ping timeout: 245 seconds]
<quazimodo>
Hi
<quazimodo>
do we have file local constants in ruby?
<Nilium>
Not that I'm aware of, unless you add something like const_missing and check the file and so on
gix has quit [Ping timeout: 260 seconds]
kies has quit [Ping timeout: 255 seconds]
agent_white has quit [Ping timeout: 272 seconds]
gix has joined #ruby
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_sfiguser has joined #ruby
segmond has joined #ruby
kies has joined #ruby
gothicsouth has joined #ruby
harfangk has joined #ruby
mrconfused has quit [Remote host closed the connection]
tristanp has joined #ruby
N0ATN has quit [Ping timeout: 240 seconds]
jtdowney has quit [Quit: Ping timeout (120 seconds)]
cgfbee has quit [Ping timeout: 245 seconds]
olson86 has joined #ruby
cgfbee has joined #ruby
__Yiota has joined #ruby
patr0clus has quit [Quit: WeeChat 1.4]
PorcoRex has quit [Quit: Leaving]
rohitpaulk has joined #ruby
tristanp has quit [Remote host closed the connection]
tristanp has joined #ruby
tristanp has quit [Ping timeout: 260 seconds]
nobitanobi has joined #ruby
jameser has joined #ruby
nobitanobi has quit [Ping timeout: 258 seconds]
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
segmond has quit [Quit: l8r]
jameser has quit [Read error: Connection reset by peer]
rohitpaulk has quit [Ping timeout: 240 seconds]
jameser has joined #ruby
belmoussaoui_ has joined #ruby
belmoussaoui has quit [Ping timeout: 240 seconds]
kies has quit [Ping timeout: 255 seconds]
renchan has joined #ruby
TomyLobo has joined #ruby
jameser has quit [Read error: Connection reset by peer]
jameser has joined #ruby
uZiel has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
uZiel has quit [Remote host closed the connection]
uZiel has joined #ruby
jameser has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Mortomes|Train has joined #ruby
zacts has joined #ruby
<zenspider>
Pongles: did you get stuff figured out?
<Pongles>
In regards to the telnet negotiation?
djbkd has joined #ruby
__Yiota has joined #ruby
mim1k has joined #ruby
herbmillerjr has quit [Quit: Konversation terminated!]
jusa has joined #ruby
arescorpio has quit [Quit: Leaving.]
Gues_____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
mim1k has quit [Ping timeout: 240 seconds]
jusa has quit [Ping timeout: 260 seconds]
tristanp has joined #ruby
knamehost has quit [Quit: Leaving]
<zenspider>
I guess
nbering has joined #ruby
cam27 has joined #ruby
<Radar>
Pongles: ^
<Pongles>
I have yet to figure that out, nor have I had a chance to work on it since
<Pongles>
I tried doing a client.read() before the first get but that appears to not work as intended
anisha_ has joined #ruby
<Radar>
zenspider: Any idea how to make Pongles code not block? I tried coming up with an answer this morning but I couldn't.
<Radar>
I'd like to see what you could come up with
<nbering>
I have a question that's about something I see in Rails a lot, but is actually a language question. I often see code in a class like ActiveRecord's has_many function, and it looks almost like an include, but it feels more like a function call. What's actually happening when that's called? Speaking broadly of the pattern, not the specific example.
<Radar>
nbering: when Ruby evaluates the class definition.
<zenspider>
Pongles: I don't know what the problem is. "not work as intended" is vague
aupadhye has joined #ruby
roshanavand has quit [Client Quit]
<Pongles>
The client.read() appears to block until newline from client
<zenspider>
yes... working as intended
<Pongles>
as I am using port 23 to mimic a telnet server, the clients are sending negotiation characters at the start of the connection
<Radar>
zenspider: I think Pongles wants the program to close the connection immediately when the client closes their connection. Right now it just waits for further input.
<nbering>
Radar: Thank you very much. Smells like a rabbit hole indeed, but now I know where to look for it.
<Pongles>
and I am trying to make it so they don't get added to the userid variable
<Pongles>
@Radar, no
<Radar>
ok, I'll let you explain it
<Pongles>
I thought I did
nbering has quit [Quit: Leaving...]
<zenspider>
`client.gets.chomp.to_s` is blocking code. as defined.
<Pongles>
client.gets.chomp.to_s is not client.read
<Pongles>
I have been having troubles trying to ignore the negotiation characters at the start of the connection from the client
roshanavand has joined #ruby
<Pongles>
I tried client.read at the start to swallow them, but it didn't work
<zenspider>
doesn't matter. They BOTH block, *AS DEFINED*
<Pongles>
I NOTICED
kies has joined #ruby
<Pongles>
That's not the problem though
karlding has joined #ruby
<Pongles>
The problem is that I need to figure out a way to ignore the negotiation characters at the start of the connection that the client sends
<zenspider>
you can't ignore them. try again
<Pongles>
...
roshanavand has quit [Read error: Connection reset by peer]
roshanavand1 has joined #ruby
<zenspider>
they're sent over an IO that you're trying to use...
<zenspider>
what do you really want?
<Pongles>
did you ping me about my issue hours later just to troll me?
<zenspider>
clearly
roshanavand1 has quit [Client Quit]
<zenspider>
or you could do better than spend 10 minutes NOT describing your problem, and when obvious issues are brought up, you could address them
roshanavand has joined #ruby
<zenspider>
you can't "ignore" the negotiation. You have to do something with the IO to get the meat you do want
<Pongles>
I am fine with *getting* the characters and then doing nothing with them
<zenspider>
so just to be really clear... blocking is NOT the issue at all?
<Pongles>
I just need them to not be part of userid
<zenspider>
are they fixed length? or fixed format?
<Pongles>
blocking was never the main issue, it was just a side effect of the method I tried to fix
roshanavand has quit [Client Quit]
<Pongles>
they are not fixed length, but they do have a standard format
roshanavand has joined #ruby
<zenspider>
so you'll need to write some sort of (no-op) parser for it, reading n chars at a time (even 1) until it is gone
roshanavand has quit [Client Quit]
roshanavand has joined #ruby
<zenspider>
IO has #ungetc so you can put BACK a char if you go past the last negotiation sequence
<zenspider>
even something as dumb as: c = io.getc until c == "\0";
TomyWork has quit [Remote host closed the connection]
bokayio has quit [Ping timeout: 240 seconds]
bokayio has joined #ruby
gf3 has joined #ruby
ferr1 has joined #ruby
<kke>
how would i make my own Foo("123") coercer thing, like Integer("123"), Array(foo), etc?
<dionysus69>
btw I made a script to auto upload youtube videos based on what data is in google sheets https://github.com/webzorg/google-api-automation, maybe someone may use it as a template :)
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<canton7>
kke, 'def Foo(input) ...'
<kke>
monkeypatching Object i guess
<ljarvis>
you don't need to monkeypatch Object
<kke>
or Kernel. isn't that what you are monkeypatching if you run `def foo` from main?
oliv_____ has quit [Remote host closed the connection]
bernd9000 has quit [Remote host closed the connection]
yogg-saron has joined #ruby
jane_booty_doe has joined #ruby
im0nde has joined #ruby
im0nde has quit [Client Quit]
im0nde has joined #ruby
Burgestrand has joined #ruby
mim1k has quit [Ping timeout: 255 seconds]
jane_booty_doe has quit [Quit: Leaving]
jane_booty_doe has joined #ruby
bkxd has joined #ruby
jane_booty_doe has quit [Remote host closed the connection]
jbdoe has joined #ruby
oliv_____ has joined #ruby
jbdoe has quit [Remote host closed the connection]
oliv_____ has quit [Remote host closed the connection]
oliv_____ has joined #ruby
ltem has quit [Quit: Leaving]
bweston92 has quit [Quit: Connection closed for inactivity]
oliv_____ has quit [Remote host closed the connection]
oliv_____ has joined #ruby
belmoussaoui has quit [Ping timeout: 245 seconds]
synthroid has joined #ruby
belmoussaoui has joined #ruby
xall has joined #ruby
jgt has quit [Ping timeout: 255 seconds]
belmoussaoui__ has joined #ruby
xall has quit [Client Quit]
belmoussaoui has quit [Ping timeout: 246 seconds]
pandaant has quit [Remote host closed the connection]
sepp2k has joined #ruby
sepp2k has quit [Client Quit]
sepp2k has joined #ruby
pupsicle has joined #ruby
<dminuoso>
asm>> Array(1..2)
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/807655
<dminuoso>
asm>> Foo(1..2)
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/807656
<dminuoso>
kke: If you use load you have already subscribed to the special semantic it incurs.
Guest____ has joined #ruby
Guest____ has quit [Client Quit]
mostlybadfly has joined #ruby
jenrzzz has joined #ruby
hashrocket has joined #ruby
djbkd has quit [Remote host closed the connection]
nobitanobi has joined #ruby
djbkd has joined #ruby
konsolebox has joined #ruby
djbkd has quit [Remote host closed the connection]
teclator has joined #ruby
djbkd has joined #ruby
rgr has joined #ruby
PatrikasZvaigzde has quit [Ping timeout: 245 seconds]
PatrikasZvaigzde has joined #ruby
djbkd has quit [Ping timeout: 260 seconds]
shinnya has joined #ruby
jaruga_________ has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
tomphp has joined #ruby
mim1k has joined #ruby
roamingdog has joined #ruby
bruce_lee has joined #ruby
bruce_lee has joined #ruby
bruce_lee has quit [Changing host]
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
belmoussaoui__ has quit [Ping timeout: 255 seconds]
yogg-saron has joined #ruby
jane_booty_doe has joined #ruby
Burgestrand has quit [Quit: Closing time!]
haylon has joined #ruby
opencw has quit [Quit: Leaving]
opencw has joined #ruby
stupidsenpai has joined #ruby
jgt has joined #ruby
kthibodeaux has joined #ruby
stupidsenpai has quit [Read error: Connection reset by peer]
saschavoid has joined #ruby
mim1k has quit [Ping timeout: 260 seconds]
apparition has joined #ruby
pandaant has joined #ruby
jusa has joined #ruby
pandaant has quit [Remote host closed the connection]
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vali has quit [Quit: vali]
roamingdog has quit [Ping timeout: 245 seconds]
quazimodo has joined #ruby
jusa has quit [Ping timeout: 260 seconds]
sysanthrope has quit [Remote host closed the connection]
<kke>
yes. just hypothesising.
sysanthrope has joined #ruby
gnufied has joined #ruby
yottanami has joined #ruby
<yottanami>
How can I write this code `total = 0;@products.each{|product| total += product.price}` using reduce?
<dminuoso>
kke: Though no, it does not execute like you suggested.
dionysus69 has quit [Ping timeout: 240 seconds]
bkxd has quit [Ping timeout: 255 seconds]
<apeiros>
kke: proper way to define Foo() is `module Kernel; module_function def Foo(…) … end; end`
<dminuoso>
kke: Basically the main difference between the two is that require will not require the same file twice, whereas load will do it again. And load has a second argument (which is not very useful)
mim1k has joined #ruby
<apeiros>
yottanami: @products.inject(0) { |sum, product| sum + product.price }
<apeiros>
dminuoso: don't forget about suffix requirement
<dminuoso>
apeiros: mine is shorter! and slower!
<apeiros>
dminuoso: shame on you for using &:+ instead of :+, also it's not equivalent without 0 as initial value
<dminuoso>
apeiros: Oh. I keep forgetting which stupid enumerable methods support symbols and which dont.
<apeiros>
basically inject. only. nothing else.
<dminuoso>
Or idk. You are right.
<dminuoso>
Haha ok
ur5us has joined #ruby
<dminuoso>
fine
<apeiros>
I still wish others would too
<dminuoso>
@products.map(:price).inject(:+) || 0
<apeiros>
like map, select, reject
<dminuoso>
apeiros: ^- ?
<cjohnson>
Would anybody mind taking a quick look at my exercise and tell me things I could have done better? This is beginner stuff so don't go too crazy but if I did any obviously silly things let me know: https://gist.github.com/chrisjohnson/af563f8c350e7e863c07b730812fee4a
<herwin>
@products.map(:price).sum
<apeiros>
yes. I'd love it if that'd work as intended. alas it doesn't.
<apeiros>
all identifiable things in ruby have their identification as symbols
<cjohnson>
got it
<apeiros>
so "yes, all methods have symbols" if you accept bad wording :-p
<cjohnson>
I'm newb, accept my bad wording for now please lol
<apeiros>
proper: "yes, all methods are identified by a symbol"
rgr has quit [Quit: rgr]
<cjohnson>
so in JS you can pass functions around as first class values. In ruby it seems like if you want to pass a method you want to pass its symbol
<dminuoso>
cjohnson: It depends.
<dminuoso>
cjohnson: You can also pass methods as first class values
<dminuoso>
it just takes a little extra effort to do so.
<elomatreb>
You can detach methods, but you need to attach them again if you want to call them
<dminuoso>
^-
<cjohnson>
dminuoso: can you give an example?
<apeiros>
it's gotten a bit trickier to prove that since ruby seems to create symbols more eagerly. but back in the days you could prove it by: `before = Symbol.all_symbols.dup; def foobarbaz; end; p(Symbol.all_symbols - before)`
<apeiros>
it'd print "[:foobarbaz]"
<dminuoso>
>> a = "foo".method(:length); p a
<ruby[bot]>
dminuoso: # => #<Method: String#length> ...check link for more (https://eval.in/807771)
<dminuoso>
cjohnson: ^-
<dminuoso>
cjohnson: but yeah, you'd usually go the symbol way
<dminuoso>
cjohnson: the interesting thing is, when you do "foo".length what actually happens internally is "foo".send(:length)
kubunto has joined #ruby
<dminuoso>
which is why using symbols is about as good.
<cjohnson>
gotchya, that makes sense. so everything in ruby is implemented as a method basically?
<cjohnson>
as far as operations
<dminuoso>
cjohnson: No.
<cjohnson>
ha
<apeiros>
cjohnson: there are some syntax operations. but they are rare.
<dminuoso>
cjohnson: There's some things that are optimized away.
<apeiros>
defined?, &&, || and a couple of others
<apeiros>
alias
<apeiros>
super
<cjohnson>
oh yeah good call
<apeiros>
those are probably the most common syntax based operations
<cjohnson>
those make sense
<matthewd>
But yes, most operators are methods
<apeiros>
stuff like +, -, ^, =~, [], []= etc. are despite their look actually methods
<dminuoso>
cjohnson: for example: 1+2 is not a method
<dminuoso>
asm>> 1+2
<ruby[bot]>
dminuoso: I have disassembled your code, the result is at https://eval.in/807774
HoierM has joined #ruby
<cjohnson>
Isn't that slow?
<dminuoso>
cjohnson: it's built as an immediate optimized vm instruction.
<cjohnson>
gotchya
<apeiros>
e.g. `foo[123, 45] = 67` is actually `foo.[]=(123,45,67)`, or `foo.send(:[]=, 123,45,67)`
<dminuoso>
cjohnson: And yes, the worst part because methods can be monkey patched by anyone at any time, it leads to horribile performance.
<apeiros>
dminuoso: makes me wonder whether ruby 3 will finally have that deoptimization thingy in it. they wanted to speed up arithmetic operations for inferred types and only deoptimize in case any of those get overridden (which happens almost never)
__Yiota has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<matthewd>
dminuoso: Except yes it is a method
<cjohnson>
So what is the general stance? Do seasoned rubyists tend to scoff at a lot of metaprogramming because it leads to bad performance?
<dminuoso>
matthewd: Oh. oh. Yes.
<cjohnson>
or are there good ways to get good performance without giving it all up
<dminuoso>
You are right.
<matthewd>
The fact the implementation has a shortcut for the default behaviour doesn't change that.
<dminuoso>
cjohnson: No, the performance penalty has been incurred when you use Ruby.
<apeiros>
and that penalty isn't as bad anymore as it used to be
<dminuoso>
cjohnson: The mere fact that it *is* possible prevents Ruby from doing trivial optimizations.
<cjohnson>
yeah
<cjohnson>
ok that makes sense
<apeiros>
the general consensus is that in most code it doesn't matter and that ruby saves enough time to rewrite sensitive stuff in native code if necessary.
<apeiros>
and in most cases it becomes evident that it isn't actually necessary
<apeiros>
so you just get the saved time ;-)
<cjohnson>
Ha
<cjohnson>
Yeah I get that, coming from JS and PHP
<dminuoso>
cjohnson: Though if you look at chrisseaton's (et al) truffle/graal you can actually see amazing JIT behavior that can tackle these dynamic portions
<dminuoso>
and bring Ruby in line with Java in terms of performance
<cjohnson>
spent a lot of time telling C++ devs to chill out about performance
<cjohnson>
hrm
<dminuoso>
cjohnson: So it can be optimized. But MRI doesn't do much (yet)
<apeiros>
bottom line: ruby is not the best choice for everything. now replace "ruby" with anything.
<cjohnson>
ha
<dminuoso>
cjohnson: In fact Ruby only optimizes the most trivial cases during compile time, and then tries to do the rest with heavy caching and cache invalidation strategies left and right.
<elomatreb>
No, Javascript is obviously the perfect language and is probably what the universe is implemented in
<cjohnson>
Seems like that leads to limited static analysis tooling
yottanami has quit [Ping timeout: 240 seconds]
<dminuoso>
cjohnson: Indeed.
<cjohnson>
can you lint ruby very well?
<dminuoso>
No.
<cjohnson>
I see
<elomatreb>
It does, you need to write extensive comments for documentation
<dminuoso>
Only for style mostly.
<cjohnson>
elomatreb: lol yeah so then the answer is no
<cjohnson>
hahaha
<apeiros>
elomatreb: you surely meant lisp
<dminuoso>
cjohnson: But the dynamic nature makes static analysis completely impossible. something like flowtype is not possible in pure ruby
<dminuoso>
cjohnson: However there's Crystal.
<elomatreb>
cjohnson: I was replying to "Seems like that leads to limited static analysis tooling" ;)
<cjohnson>
Fair. Either way, if it relies on commenting, that means it's pretty limited imo
<cjohnson>
most of those tools are there to catch things I didn't think of
<cjohnson>
imo anyway
<dminuoso>
cjohnson: The fact that you can brutally pry into ObjectSpace means you can globally fuck around with any object
<dminuoso>
from anywhere.
<dminuoso>
Which makes it impossible for any static tool to reason about anything.
<cjohnson>
So there's no such thing as a sandboxed namespace that is safe from being touched by other code?
<elomatreb>
The flipside of the Rust strategy of having programmers fight the compiler to get the program running
<matthewd>
cjohnson: Correct
<dminuoso>
elomatreb: Im not convinced. The program compilers if your semantics are right, and if the compiler emits errors it means your program is wrong.
beccamorgan has joined #ruby
<dminuoso>
*the compiler errors..
<dminuoso>
err *the program compiles..
<dminuoso>
too hot. way too hot.
<elomatreb>
Of course, but it makes translating the abstract concept of what you want to implement into code which the compiler then can translate harder
<dminuoso>
elomatreb: In JS I find myself spending all that time "saved fighting the compiler" writing tests and flowtype definitions to ensure that proper semantics are preserved. So basically voiding all that effort saved. :P
<matthewd>
dminuoso: if the compiler emits errors it means the compiler can't prove that your program is right
<dminuoso>
matthewd: No, but it can prove its wrong.
<dminuoso>
Ruby doesn't do either.
<dminuoso>
Or rather JS since that was the basis of this discussion.
railswebdev has joined #ruby
tvw has joined #ruby
<dminuoso>
matthewd: Mind my asking since I was curious anyway. Do you contribute to Rails for a living?
kubunto is now known as kubunto|afk
chouhoul_ has joined #ruby
<matthewd>
Not particularly. Mostly free time, but if my employer has a specific need, then I'm obviously well placed to help stuff happen.
jane_booty_doe has quit [Quit: Leaving]
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
GodFather has quit [Ping timeout: 240 seconds]
bkxd_ has joined #ruby
bkxd has quit [Ping timeout: 246 seconds]
tomphp has joined #ruby
eblip has joined #ruby
charliesome has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
A124 has quit [Disconnected by services]
A124 has joined #ruby
Kug3lis_off is now known as Kug3lis
94KAAUTVH is now known as nug
Kug3lis is now known as Kug3lis_off
Kug3lis_off is now known as Kug3lis
oleo has joined #ruby
charliesome has joined #ruby
<cjohnson>
It seems like blocks get some sort of special treatment when being passed into functions. For example, to pass a block to Enumerable#reduce, you can just pass it like foo.reduce { |n| ... }
ta_ has quit [Remote host closed the connection]
jrafanie has joined #ruby
<cjohnson>
But if you want to pass an initial value, it needs to be in a sorta seperate set of arguments, like: foo.reduce(0) { |n| ... }
<cjohnson>
why is that? where can I read more about that behavior? Do methods get a special "block argument" space that is separate from normal args?
<matthewd>
cjohnson: Yes, the block parameter is a syntactically separate thing
<cjohnson>
ok so it's kinda like `this` in JS
<cjohnson>
it's an argument, but it doesn't sit in the normal args list
<cjohnson>
Are you limited to one block?
<apeiros>
you can have it in the arg list too
<apeiros>
yes, one block only
<apeiros>
re in arg list: add_one = ->(n) { n + 1 }; [1,2,3].map(&add_one)
<cjohnson>
How do you access teh block? does it do anythin magic or is it just an argument that the mehtod can use how it sees fit?
LastWhisper____ has joined #ruby
<apeiros>
you can tell ruby to create an object representation of it by defining your method with a &arg: `def foo(&arg); …`
<apeiros>
the variable `arg` will then contain the block
<matthewd>
cjohnson: `yield` and `block_given?` built-ins, or &arg ^^
<cjohnson>
interesting
<apeiros>
if you don't need an object ^
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<cjohnson>
Are arguments optional? What happens if you omit a block in the def foo(&arg) ?
GodFather has joined #ruby
<apeiros>
also `Proc.new` (without a block) will create a proc from the block (that's arcane btw., not many ruby coders will understand)
<matthewd>
Block arguments are optional; others are required unless they have a default
mikecmpbll has quit [Quit: inabit. zz.]
<apeiros>
I'd amend this to: blocks are *always* optional. it'll only ever raise if it tries to actually access it.
<apeiros>
also you can pass a block to methods which don't make use of it:
<apeiros>
(NB: I don't exactly like that behavior)
mikecmpbll has joined #ruby
cdg has joined #ruby
cdg has quit [Remote host closed the connection]
patarr has joined #ruby
cdg has joined #ruby
__Yiota has joined #ruby
<cjohnson>
interesting
<apeiros>
also note that `super`'s behavior wrt blocks and arguments is super unobvious
bkxd_ has quit [Ping timeout: 260 seconds]
<apeiros>
`super` passes on all args passed to the method, `super()` will pass zero arguments, but will still pass on a block passed to the current method, `super(&nil)` passes no arguments and suppresses passing the block
hobodave has joined #ruby
<apeiros>
note that in `def foo(a,b); a = 2; super; end; foo(5, 6)` will invoke the super method with the arguments (2, 6)
belmoussaoui has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
teclator has quit [Remote host closed the connection]
<cjohnson>
oh that looks lovely lol
<cjohnson>
Thanks apeiros that is a fantastic little explanation of various gotchyas
tomphp has joined #ruby
<cjohnson>
So def foo(&block, a, b) will I call that as foo(1, 2) { |n| ... } ?
<cjohnson>
same q with foo(a, b, &block)
meshsmith has joined #ruby
<matthewd>
&block has to come last, but yes
<cjohnson>
does it just sort of pluck the &block arg out of the list? or do I need it in a certain place
<cjohnson>
oh ok
<cjohnson>
makes sense
<cjohnson>
Ok I think this is my last question for at least 10 minutes: Can you use both &block arg and the yield operator?
antgel has joined #ruby
<matthewd>
Yes (and they'll both use the same/only block)
<cjohnson>
Am I misunderstanding how to use thing = 'my thing' here? I found a similar example in that sitepoint article
<cjohnson>
My guess is probably that thing = 'my thing' needs to go in initialize
<matthewd>
cjohnson: That's setting a local variable called 'thing'
<cjohnson>
local to the instance?
<matthewd>
Local to the scope, unrelated to the accessor
__Yiota has joined #ruby
<matthewd>
You need `self.thing = ..` to call the accessor... and then yes, you'll need to put it in initialize
<cjohnson>
Ok so is the only difference the fact that I can access Foo.thing
<cjohnson>
if it's @thing
<cjohnson>
But if it's thing = 'my thing' then regardless of attr_* I can't call Foo.thing
<cjohnson>
?
<elomatreb>
No, you can access Foo.new.thing, important difference
<matthewd>
Ruby @x == JS this.x (approximately)
<havenwood>
cjohnson: `attr_accessor :thing` gets and sets `@thing` with the #thing and #thing= methods. Internally you can get and set `@thing` directly
ur5us has joined #ruby
<cjohnson>
Ok so the attr_* stuff is more for external use, but internally you can just access the var directly using @. which will bypass getters and setters logic
<matthewd>
Ruby `foo = 1` == JS `let foo = 1`
<cjohnson>
Ok, makes sense
<apeiros>
cjohnson: you can mostly forget about @@ and $
<elomatreb>
Re-implementing the attr_* methods is a great exercise btw
<apeiros>
they should only be used in exceedingly rare occasions
<cjohnson>
Oh right and for "static class" variables that's where you do class Foo; self.static_thing = 'my static value'; end
<matthewd>
Yes; attr_accessor is a shortcut for `def foo; @foo; end; def foo=(value); @foo = value; end`
<cjohnson>
And that gives me Foo.static_thing
olivi____ has quit [Remote host closed the connection]
<apeiros>
class << Foo; attr_accessor :static_thing; end
<apeiros>
for funsies
<elomatreb>
No, there are no properties in Ruby like in Javascript. Everything you access from "outside" a class is a method
<apeiros>
usually done via `class Foo; class << self; …; end; end`
u0_a190 has quit [Ping timeout: 245 seconds]
<apeiros>
(since self == Foo in that context)
<cjohnson>
elomatreb: sorry, ignoring the method part. Object.keys in JS might be defined in ruby as class Object; def self.keys... end; end
<apeiros>
yes
<cjohnson>
But Object#hasOwnProperty might be class Object; def hasOwnProperty...; end; end
olivi____ has quit [Remote host closed the connection]
<apeiros>
cjohnson: like ^
shinnya has quit [Ping timeout: 240 seconds]
<elomatreb>
apeiros' fancy client collapses ... into a proper character, I'm jealous
<apeiros>
elomatreb: no, I type it properly
<apeiros>
opt-. is … here
oliv_____ has joined #ruby
<apeiros>
with osx, you could set up a global short-cut for ... to collapse, though
<apeiros>
btw., I mostly type it properly because it's less effort :D
Flonk has joined #ruby
<baweaver>
apeiros: I'd hate OSX if it auto-collapsed that
* apeiros
is the laziest of all lazy bastards
brent__ has joined #ruby
<apeiros>
baweaver: js? :D
<baweaver>
think ranges as well
DTZUZU has quit [Read error: Connection reset by peer]
aupadhye has quit [Ping timeout: 260 seconds]
oliv_____ has quit [Remote host closed the connection]
<apeiros>
oh, right. I think I actually rarely use exclusive ranges.
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
olivi____ has joined #ruby
<baweaver>
but yeah, js too
chouhoulis has joined #ruby
<apeiros>
maaaan, I really *love* how spreadsheet gem randomly converts dates to Date instances or Floats</sarcasm>
konsolebox has quit [Quit: Leaving]
mim1k has quit [Read error: Connection reset by peer]
<baweaver>
apeiros: ask zenspider about rspec making their own inspect / pretty print interceptors
__Yiota has joined #ruby
<mikecmpbll>
:D
<apeiros>
baweaver: bah, zenspider made his own NilClass#method_missing black hole…
<apeiros>
so he clearly takes the cake in that regard :-p
<baweaver>
karma it is then
<apeiros>
anyway, all those are/were deterministic
<baweaver>
well, between that and what people like me, havenwood, Ox0dea, and banisterfiend have done to the language we're all due for some karmic fallout
brent__ has quit [Remote host closed the connection]
<apeiros>
I can't figure out when spreadsheet behaves one way or the other. I run it twice on the same data with differing results.
brent__ has joined #ruby
conta has quit [Ping timeout: 260 seconds]
<baweaver>
set_trace_func / binding.pry if value is a String and matches your data?
<baweaver>
that way you have an interceptor that can trace the caller wherever that value happens to come up as a string
<mwlang>
baweaver: heh, no kidding. apparently, my login was still “registering”
<apeiros>
I really don't get what ruby does there. if I create a BasicObject which returns itself on to_ary, ruby only ever calls to_ary once and nothing else and then raises
<apeiros>
no idea why it wouldn't raise for the Row which returns itself too
<apeiros>
aaahahaha, figured. Row < Array
<apeiros>
now I just have to figure why that in turn causes this weird conversion of Date -> Float
belmoussaoui has quit [Remote host closed the connection]
zacts has quit [Ping timeout: 255 seconds]
belmoussaoui has joined #ruby
im0nde has quit [Ping timeout: 272 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
gothicsouth has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
Cohedrin has joined #ruby
solos has quit [Ping timeout: 260 seconds]
marxarelli has joined #ruby
beccamorgan has quit [Read error: Connection reset by peer]
solos has joined #ruby
Exagone313 has quit [Quit: see ya!]
sneakerhax has quit [Ping timeout: 268 seconds]
belmoussaoui_ has joined #ruby
belmoussaoui has quit [Ping timeout: 260 seconds]
beccamorgan has joined #ruby
<cjohnson>
baweaver: lol good article
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Exagone313 has joined #ruby
beccamorgan has quit [Remote host closed the connection]
nowhereman has quit [Ping timeout: 246 seconds]
beccamorgan has joined #ruby
ascarter has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
acemo_ has quit []
acemo has joined #ruby
gusrub has joined #ruby
gusrub has quit [Client Quit]
HoierM has quit [Ping timeout: 260 seconds]
ltd has quit [Ping timeout: 268 seconds]
gusrub has joined #ruby
ltd has joined #ruby
nobitanobi has joined #ruby
yeticry_ has joined #ruby
raspado has joined #ruby
nitric has joined #ruby
ascarter has joined #ruby
yeticry has quit [Ping timeout: 268 seconds]
Nightmare has quit [Excess Flood]
hobodave has quit [Quit: Computer has gone to sleep.]
Nightmare has joined #ruby
jaruga_________ has quit [Quit: jaruga_________]
synthroid has joined #ruby
Cohedrin has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jrafanie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has joined #ruby
kubunto|afk has left #ruby [#ruby]
GodFather has joined #ruby
nowhereman has joined #ruby
kies has joined #ruby
muelleme has joined #ruby
ruby-lang972 has joined #ruby
hobodave has joined #ruby
dcunit3d has joined #ruby
__Yiota has joined #ruby
u0_a190 has joined #ruby
Cohedrin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mark_66 has quit [Remote host closed the connection]
lxsameer has quit [Quit: WeeChat 1.7]
gusrub has quit [Remote host closed the connection]
gusrub has joined #ruby
olivi____ has quit [Remote host closed the connection]
mtkd has quit [Ping timeout: 268 seconds]
mtkd has joined #ruby
ruby-lang972 has quit [Ping timeout: 260 seconds]
u0_a190 has quit [Ping timeout: 240 seconds]
belmoussaoui has joined #ruby
belmoussaoui_ has quit [Read error: Connection reset by peer]
belmoussaoui_ has joined #ruby
gusrub has quit [Ping timeout: 272 seconds]
yottanami has joined #ruby
Nightmare has quit [Excess Flood]
hutch34 has joined #ruby
belmoussaoui has quit [Ping timeout: 260 seconds]
haylon has quit [Remote host closed the connection]
jrafanie has joined #ruby
Nightmare has joined #ruby
romank has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Fernando-Basso has joined #ruby
haylon has joined #ruby
belmoussaoui has joined #ruby
haylon has quit [Remote host closed the connection]
haylon has joined #ruby
JoshS has quit [Quit: Leaving]
renchan has quit [Quit: Leaving...]
duderonomy has joined #ruby
oliv_____ has joined #ruby
belmoussaoui_ has quit [Ping timeout: 260 seconds]
Cohedrin has joined #ruby
belmoussaoui has quit [Read error: Connection reset by peer]
belmoussaoui has joined #ruby
lf_an has joined #ruby
lf_an has left #ruby [#ruby]
roshanavand has quit [Quit: Leaving.]
BTRE has quit [Ping timeout: 240 seconds]
machinewar has joined #ruby
ldnunes has quit [Ping timeout: 240 seconds]
beccamorgan has quit [Read error: Connection reset by peer]
mikecmpbll has joined #ruby
belmoussaoui has quit [Ping timeout: 246 seconds]
chalkmonster has joined #ruby
BTRE has joined #ruby
belmoussaoui has joined #ruby
gusrub has joined #ruby
ur5us has joined #ruby
belmoussaoui has quit [Ping timeout: 240 seconds]
belmoussaoui has joined #ruby
machinewar has quit []
ur5us has quit [Ping timeout: 260 seconds]
oliv_____ has quit [Remote host closed the connection]
nobitano_ has joined #ruby
shinnya has joined #ruby
<adaedra>
hi
ldnunes has joined #ruby
gothicsouth has joined #ruby
belmoussaoui has quit [Ping timeout: 246 seconds]
<havenwood>
g'mornin'
belmoussaoui has joined #ruby
ol_______ has joined #ruby
nobitanobi has quit [Ping timeout: 260 seconds]
uZiel has joined #ruby
* kenichi
waves
hutch34 has quit [Read error: Connection reset by peer]
dain has joined #ruby
<apeiros>
moin
hutch34 has joined #ruby
Didac has quit [Changing host]
Didac has joined #ruby
ol_______ has quit [Ping timeout: 255 seconds]
dain has quit [Quit: dain]
jane_booty_doe has joined #ruby
belmoussaoui has quit [Ping timeout: 245 seconds]
chalkmonster has quit [Quit: Daddy's flown, 'cross the ocean.]
yottanami has quit [Ping timeout: 268 seconds]
GinoMan has joined #ruby
normie1 has joined #ruby
jane_booty_doe has quit [Client Quit]
oliv_____ has joined #ruby
mim1k has joined #ruby
beccamorgan has joined #ruby
DLSteve_ has joined #ruby
dc2 has joined #ruby
beccamorgan has quit [Remote host closed the connection]
dcunit3d has quit [Ping timeout: 240 seconds]
belmoussaoui has joined #ruby
yottanami has joined #ruby
beccamorgan has joined #ruby
hobodave has quit [Remote host closed the connection]
mim1k has quit [Ping timeout: 260 seconds]
hobodave has joined #ruby
jgt has quit [Ping timeout: 255 seconds]
lxsameer has joined #ruby
workmad3 has quit [Ping timeout: 240 seconds]
kirun has joined #ruby
donald has joined #ruby
<donald>
hi
jgt has joined #ruby
<donald>
is there a french irc channel about ruby?
CacoS has quit [Remote host closed the connection]
<matthewd>
If the file's not utf-8, it might be wiser to read it in the encoding it's actually using
<ule>
matthewd: but my db is utf-8 so I need to convert it anyways
__Yiota has joined #ruby
ecuanaso has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ule>
apeiros: checking that scrub()
<matthewd>
Yes. *Convert*.
<apeiros>
matthewd: and that'd be "but I ask" :)
<ule>
matthewd: but that was the problem.. I converted and it changed to \86
<apeiros>
ule: how do you figure your input is utf-8?
belmoussaoui_ has joined #ruby
<ule>
apeiros: string.encoding
<apeiros>
well, you *think* you converted it. we saw how you're "converting" stuff above.
<apeiros>
ule: see, that doesn't do what you think it does.
<ule>
lol
<apeiros>
String#encoding tells you what *you* told ruby the encoding was
<apeiros>
and *you* told ruby in this case most probably by just keeping the defaults
Fernando-Basso has quit [Quit: WeeChat 1.8]
rohitpaulk has quit [Remote host closed the connection]
belmoussaoui has quit [Ping timeout: 240 seconds]
<apeiros>
so no, String#encoding is not a way to figure the encoding of data you're reading. it's a way to figure as what ruby will treat it (which in turn is based on what you tell it to)
<ule>
apeiros: how can I just identify if the string has some fancy characters like those ones you sent in your german/swiss email?
<apeiros>
string.b.scan(/[\x80-\xff]{2,}/)
<apeiros>
run that, show us the first couple results
<apeiros>
whoops, add an n flag to the regex (//n)
belmoussaoui has joined #ruby
<apeiros>
hm, maybe this is even better: string.b.scan(/\w*[\x80-\xff]{2,}\w*/n)
<apeiros>
will give us a bit of context
<ule>
ok lemme check
<apeiros>
(you can output it using p, e.g. `p string.b.scan(/\w*[\x80-\xff]{2,}\w*/n).first(5)`)
roamingdog has joined #ruby
olivi____ has quit [Remote host closed the connection]
belmoussaoui_ has quit [Ping timeout: 246 seconds]
<dminuoso>
apeiros: Do you have that encoding gist handy?
<ule>
apeiros: I'm definitely gonna be reading that
<dminuoso>
apeiros: Had a funny discussion the other day when someone asked about his language he was designing how to handle strings. And I asked him: "What do you understand as a string?"
<baweaver>
Dumme Verwirrung?
<apeiros>
dminuoso: do go on? :)
* apeiros
actually has a ton of concepts on how to implement strings low level to handle different situations performantly or compactly
<dminuoso>
apeiros: Ended up displaying Haskell is the best example, since it takes all 3 ways to consider "strings" and provides them as different types.
olivi____ has quit [Ping timeout: 260 seconds]
<apeiros>
says "all" and "3" in the same phrase…
<apeiros>
I'm not sure which one of these you consider correct :-p
<apeiros>
which 3 ways does haskell provide?
<dminuoso>
apeiros: String, Text and ByteString
<apeiros>
I guess bytearray and character/codepoint array? which is the third?
yottanami_ has joined #ruby
<ule>
apeiros: it's actually showing []
<apeiros>
ule: ok, then you most likely do not have utf-8
<ule>
yes
<apeiros>
and given the string you already showed, it's not utf-16 or -32 either
milardovich has quit [Ping timeout: 246 seconds]
<dminuoso>
apeiros: Well and then there is [Char] ..
<ule>
I'm getting this with string.encoding: #<Encoding:ASCII-8BIT>
<apeiros>
ule: change to `p string.b.scan(/\w*[\x80-\xff]+\w*/n).first(5)` please
<apeiros>
yes. string.b changes the encoding to ascii-8bit
<ule>
["com\x86"]
<apeiros>
in *all* your input data, all you get is the above?
<dminuoso>
apeiros: So the question is: Is a string just a concatenation of bytes (C char array). Is it a concatenation of code points? (Thing c++ std::basic_string), if so, how are multi-byte code points implemented?
<ule>
no
<ule>
apeiros: it's just one line of the csv
Dwarf-br has joined #ruby
<dminuoso>
Is it done with wide characters? Or spanning over multiple single characters? if so, how is length/truncation handled in the latter
<dminuoso>
Is encoding information attached?
<dminuoso>
Or maybe font face information
<apeiros>
ule: … if you think a *single* point of information is enough, you're wildly mistaken.
dionysus70 has joined #ruby
Fernando-Basso has joined #ruby
<ule>
apeiros: I mean.. in this .csv it's just one line.. but definitely I'm gonna get more in the future
<apeiros>
"multibyte codepoint" the multibyte aspect is irrelevant if you handle it as codepoints (other than having to know the maximum value for a codepoint)
<dminuoso>
apeiros: No it is not!
<apeiros>
it is. because codepoint != bytes
ace05 has joined #ruby
__Yiota has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<dminuoso>
apeiros: Think std::basic_string<wchar_t> and std::basic_string<char>
<dminuoso>
apeiros: You can throw an UTF8 string into both.
<dminuoso>
Linux uses the latter, Windows the former.
dionysus69 has quit [Ping timeout: 240 seconds]
dionysus70 is now known as dionysus69
<dminuoso>
The first one is far more comfortable to use but wastes tons of space.
<apeiros>
if it matters, then you don't have a codepoint array.
<apeiros>
you may have fancy facades, but in the end you have a bytearray.
hahuang65 has quit [Ping timeout: 240 seconds]
<dminuoso>
apeiros: My point is, there's enough examples to show how inconsistent implementations can be/
<apeiros>
or rather, codepoint list (array already comes with a lot of connotation on how it's stored in memory)
<dminuoso>
apeiros: This codepoint array is a nice idea (and Windows does this excessively - sadly), but it performs really horrible.
<dminuoso>
It drastically increases cache pressure and increases memory usage.
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<apeiros>
I'd guess a 4byte array would perform quite well. it'd just use a ton of space.
<apeiros>
but yeah, I doubt codepoint lists are the way to go for everyday strings
<dminuoso>
apeiros: In worst case, and considering how most of the time you only use ASCII compatible codepoints, you quadruple the cache pressure.
<dminuoso>
(Which is far worse than actual memory usage)
<apeiros>
you can have a codepoint array which adapts to its data
<apeiros>
that's the point I tried to make when I replaced array with list
<dminuoso>
apeiros: Worst case would be a single non-ascii compatible codepoint in a long string then.
<dminuoso>
Or would you use a linked list of arrays?
<apeiros>
how you store it in memory is a different thing from what you store
<dminuoso>
apeiros: Well if you say "array of codepoints" its already an implementation detail, isnt it?
<apeiros>
or a skip list, or ropes, or a custom data format. sure.
<dminuoso>
apeiros: I mean the naive user expects an "array of characters"
<dminuoso>
whatever their codepoints are
<dminuoso>
(Which is what Ruby does)
<apeiros>
no, array really just means sequential data. but yes, hence my "array already comes with a lot of connotation on how it's stored in memory"
<dminuoso>
mmm
<apeiros>
and hence my "list instead of array"
<apeiros>
but there really isn't any loaded term for the abstract concept anymore
<apeiros>
ule: well, from that single data point it looks like erroneous data.
<apeiros>
ule: does the supplier of the data not tell you the encoding of the data? because really, that's the only *really* reliable way.
belmoussaoui_ has joined #ruby
belmoussaoui has quit [Ping timeout: 260 seconds]
spheric has quit [Ping timeout: 240 seconds]
gil_ has quit [Ping timeout: 272 seconds]
gil_ has joined #ruby
gil_ has joined #ruby
gil_ has quit [Changing host]
cdg_ has quit [Ping timeout: 240 seconds]
jusa has quit [Ping timeout: 260 seconds]
<ule>
apeiros: Yeah.. I'm gonna investigate that
synthroi_ has quit []
<ule>
apeiros: for now, I believe that the best thing to do is catch these erroneous lines and throw a message saying "check this line, it must be wrong"
cdg has joined #ruby
<apeiros>
that's sensible
gothicsouth has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<apeiros>
have your strings encoded as utf-8, then you can use: string.valid_encoding?
<apeiros>
and .valid_encoding? checks whether any such bytes are present
<ule>
apeiros: make sense
<apeiros>
dminuoso: I suggested .valid_encoding? and it makes sense for this task. assume it's utf-8, verify with .valid_encoding?, inform user that it contains data to be inspected if it's not valid.
<dminuoso>
mmmm
<dminuoso>
apeiros: I'd be lazy and use rchardet
<dminuoso>
Because fuck encoding.
tomphp has quit [Client Quit]
<apeiros>
dminuoso: you'd make things worse
<apeiros>
IME rchardet and consorts are terribad at correctly guessing the encoding.
gil_ has joined #ruby
gil_ has joined #ruby
gil_ has quit [Changing host]
tomphp has joined #ruby
olivi____ has joined #ruby
<dminuoso>
apeiros: It's bad enough I have to deal with CR+LF, LF, CR issues every week..
<apeiros>
those are easy
<dminuoso>
apeiros: That depends on what you are doing.
<apeiros>
gsub(/\r\n?|\n/, "\n")
<dminuoso>
apeiros: Do you do this everytime you File.read?
<apeiros>
there, normalized to \n all variants I know about
<apeiros>
no. but I consume sane data.
<dminuoso>
apeiros: Heh.
<apeiros>
I do it in one case where users can upload csv.
<apeiros>
and there I have a custom heuristic to determine whether it's utf-8, utf-16, windows-latin1 or macroman
<dminuoso>
apeiros: It's easy if you are limited to one particular language.
<apeiros>
and a custom heuristic to determine whether it's craptastic excel csv which thinks the C in csv stands for "semicolon"
* ule
learning a lot about encoding
<dminuoso>
apeiros: Do you have any French in your company?
<apeiros>
dminuoso: yes and yes
<dminuoso>
apeiros: haha!
* ule
starting to hate encoding as well
<apeiros>
ule: don't. learn how it works
Dwarf-br has quit [Ping timeout: 240 seconds]
<dminuoso>
ule: Go solve it by inventing a unified encoding for them a..
<ule>
dminuoso: apeiros we have french/canadian encodings here as well
<apeiros>
the only bad part about encodings is the lack of containers which contain the metadata.