RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
pawnbox has joined #crystal-lang
lacour has quit [Quit: Leaving]
pawnbox has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 246 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 268 seconds]
<crystal-gh> [crystal] spalladino opened pull request #4091: Parse suffix if/unless in macros after macro var (master...fix/4087-parse_suffix_if_in_macros) https://git.io/vyYMK
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
olbat has quit [Ping timeout: 268 seconds]
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
VectorGraphics has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
ssvb has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
snsei has quit [Remote host closed the connection]
sz0 has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
akwiatkowski has joined #crystal-lang
VectorGraphics has quit [Quit: Leaving]
Qchmqs has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
pawnbox_ has joined #crystal-lang
Qchmqs has quit [Ping timeout: 260 seconds]
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 264 seconds]
pawnbox has joined #crystal-lang
mark_66 has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 246 seconds]
gloscombe has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
bjz has joined #crystal-lang
akwiatkowski has joined #crystal-lang
<FromGitter> <crisward> Any way to get the last line of a file? can't see `File.tail`
theodorton has quit [Quit: theodorton]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
theodorton has joined #crystal-lang
theodorton has quit [Client Quit]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
theodorton has joined #crystal-lang
<FromGitter> <lhz> @crisward: unless you have some special knowledge about the content, you'd most likely need to read each line from the start and discard everything except the last line read. for all you know, it could all be one long line.
soveran has quit [Remote host closed the connection]
<FromGitter> <crisward> I'm creating the file, it's a log file and I just want to get the last line. I'm using ``tail -n 1 my.log``
<FromGitter> <crisward> Hopefully someone here understands memory better than me. My crystal process, using GS.stats has a heap of 3mb. However if I use top, the RES column says 9mb and the docker container it's running in says it 9.8mb. If anyone can explain this I'd be very interested. What I suppose I need to know is how much memory is crystal actually using?
<FromGitter> <crisward> line from top ⏎ ⏎ ```15 herokui+ 20 0 100.7m 9.3m 5.3m S 0.0 0.1 0:06.53 app```` [https://gitter.im/crystal-lang/crystal?at=58b6b129e961e53c7f83211b]
<FromGitter> <crisward> Ok.. I think the heap = RES - SHR. Which would be about right
stennowork has joined #crystal-lang
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 246 seconds]
<stennowork> is the github user Nax in here? i have a question regarding something unrelating (i.e. the nethack dumplog patch and its inclusion in the official source)
<stennowork> unrelated*
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Qchmqs has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
fazibear has joined #crystal-lang
stennowork has left #crystal-lang ["Leaving"]
akwiatkowski has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] asterite closed pull request #4091: Parse suffix if/unless in macros after macro var (master...fix/4087-parse_suffix_if_in_macros) https://git.io/vyYMK
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vy3et
<crystal-gh> crystal/master f58fd86 Santiago Palladino: Parse suffix if/unless in macros after macro var...
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<crystal-gh> [crystal] asterite closed pull request #4068: Fixes #4060 (master...patch-1) https://git.io/vyeJA
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vy3Jk
<crystal-gh> crystal/master e586dd2 Ary Borenszweig: Compiler: correctly copy anonymous struct types from other contexts. Fixes #4078 . Fixes #4082
<crystal-gh> [crystal] asterite closed pull request #4082: Fix: Check return pointer of LLVMGetStructName [#4078] (master...fix-llvm-type-get-struct-name-segfault) https://git.io/vykW7
A124 has quit [Ping timeout: 268 seconds]
soveran has quit [Remote host closed the connection]
A124 has joined #crystal-lang
A124 has quit [Changing host]
A124 has joined #crystal-lang
Qchmqs has quit [Ping timeout: 246 seconds]
akwiatkowski has joined #crystal-lang
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<travis-ci> crystal-lang/crystal#2e61cca (master - Fixes #4060 (#4068)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/206640005
bew78 has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e586dd2 (master - Compiler: correctly copy anonymous struct types from other contexts. Fixes #4078 . Fixes #4082): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/206642974
<DeBot> https://github.com/crystal-lang/crystal/issues/4078 (New compiler crash in 0.21.0 when building my complex project) | https://github.com/crystal-lang/crystal/pull/4082 (Fix: Check return pointer of LLVMGetStructName [#4078])
<bew78> Hello, why this doesn't work: https://carc.in/#/r/1olg ? I'm trying to debug macro %variables
<RX14> bew78, fresh variables aren't available in macros
<RX14> as in, the macro language itself
<RX14> imagine a fresh variable as just being a variable with a random name
<RX14> it's still a variable
<RX14> it still exists at runtime
<RX14> and therefore can't be "printed" by a macro because it doesn't have a value yet
<FromGitter> <drosehn> it's the complain that 'puts' is not something that the macro processor can expand?
<RX14> the puts error is weird
<RX14> i think it's just wrong
<bew78> oh there are runtime variable :( Is there a way to have compile time variables ?
<RX14> yes
<RX14> use a variable in the {{ }} blocks
<RX14> everything outside {% %} is runtime
<RX14> everything inside is compile-time
<RX14> sort of
<RX14> well
<RX14> everything in {{ }} anmd {% %} is the crystal macro language
<RX14> which can have variables
<RX14> and is compile-time
<crystal-gh> [crystal] bcardiff opened pull request #4094: Fix 3988 (master...fix-3988-b) https://git.io/vy3ot
<bew78> so cool, thanks RX14 ! I've seen somewhere that a macro must contain all it's code, and cannot delegate code generation to kind of sub-macros (like compile time functions, called from macros..), do I understand it well ?
<RX14> you can call macros from macros
<RX14> but it's quite slow
<RX14> as it runs in multiple "passes"
gloscombe has quit [Remote host closed the connection]
<RX14> the entire macro expansions are just looped over, expanding macros, until they stop changing
<RX14> so you can call macros from macros
<RX14> but you can't write your own functions which you can use inside {{ }} or {% %}
<FromGitter> <drosehn> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58b7110121d548df2c77df2a]
<FromGitter> <drosehn> @crisward : One cheaper way to implement your own `tail` would be to open the log file, use `seek` to position yourself near the end of the file, and then have a loop reading forward. Unless those reads start at position-0 in the file, you should assume that you're landing in the middle of a line. That means you must ignore everything before the first `\n` (unless you know that you're starting at position 0). Then just read
<FromGitter> ... forwards keeping track of the most recent line.
<FromGitter> <drosehn> @crisward : Note that you'd first want to call `File.stat` to know what the size of the file is. If you're going to check the last 300 bytes of the file, then you want to make sure the file *has* at least 300 bytes in it!
<FromGitter> <drosehn> @crisward : there are some other details I'm skipping over. I have not implemented `tail` in crystal, but I've done it in other languages.
<FromGitter> <drosehn> (if the file has less than 300 bytes, then don't bother with the `File.seek` and just read the entire file)
<FromGitter> <drosehn> I should note that it isn't really `File.seek`. The `seek` method is on an `IO::FileDescriptor`, as described at: https://crystal-lang.org/api/IO/FileDescriptor.html
<FromGitter> <crisward> @drosehn thanks. Crystal seems to be adding more file methods. My use case is on a known file for now so shelling out is fine. I'll take a look at file seek though, sounds interesting.
<FromGitter> <drosehn> I suspect that `tail` would be a method to add to FileUtils.
<bew78> RX14: why can't we define our own {{ my_function }} ? You mean 'currently we can't do that' or 'we don't want you to be able to do that' ?
<RX14> well it's kind of both
<RX14> i don't think it's really neccesary
<RX14> most of the time you can achieve it by pasing macro vars into another function
<RX14> plus it acts as a natural limiter for macro complexity
<RX14> i don't want crystal to turn into mostly macros
<RX14> macros should be the exception, and magic should be limited
<bew78> Ok I understand, thanks
<bew78> I have another question, is there a way to re-open String to change the meaning of some operators, but only in a specific block?
akwiatkowski has quit [Ping timeout: 240 seconds]
<RX14> not only in a specific block
<RX14> also, what you want to do is magic
<RX14> it just sounds super weird to me
<RX14> if you want to change string ops in only certain places wrap string
<bew78> yes ^^ I could but the native String won't be detected as my String wrapper...
<bew78> like `"blabla" + "something else"`
<bew78> I'd like to override the + here
<RX14> why?
<RX14> why would you want to do that?
<FromGitter> <fridgerator> just make a new method
<bew78> to make DSL in crystal for crystal..
<RX14> well if it's a DSL it's describing something abstract
<RX14> and therefore it shouldn't be a string
<bew78> I agree the + is not very clear.. Using `"blabla" | "something else"` in a parser generator would lead to an object describing a string consumer that can parse either "blabla", either "something else".... I'd like to be able to do this
<RX14> hmm
<RX14> i'd try as hard as you can to wrap the strings
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<crystal-gh> [crystal] matiasgarciaisaia opened pull request #4095: `crystal --version` reports LLVM_VERSION (master...feature/llvm-version) https://git.io/vy3HI
<bew78> RX14: I tried simple stuff in macro (should be possible), but I get a weird error, the assignement doesn't work as I think it should... https://carc.in/#/r/1olt
soveran has quit [Remote host closed the connection]
ssvb has joined #crystal-lang
<bew78> why does the value of the macro variable assignation is used as macro expansion content ?
Ven has joined #crystal-lang
<FromGitter> <asterite> bew78: {{ ... }} will write the expression to the macros' output, you probably want {% ... %} here
<bew78> Oh yes, RX14 said something about macro variables in {{ }}, then in {% %}, and I mis-understood.. thanks
bjz has joined #crystal-lang
<FromGitter> <drosehn> Hmm. I tried `{% puts %line2 %}` and that also got the error about `undefined macro variable 'puts'`
<RX14> because %line2 doesn't make sense in a macro
<RX14> not really
<RX14> i think it's doing weird things top the lexer/parser/compiler
<FromGitter> <drosehn> I'm just guessing my way through this, because I don't really have a good picture in my head of what's going on. (which is my own fault. I haven't looked into macros all that much)
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<Papierkorb> drosehn, I think you're just confusing the different run times. Macros are expanded (= run) at compile-time, at run-time they just don't exist anymore. Normal code runs at run-time, and is processed during compile-time. You can think of macros being a program on its own: It can't know what the value of `%line2` will be, that would require a time machine :)
michael_campbel- has joined #crystal-lang
michael_campbell has quit [*.net *.split]
akwiatkowski has joined #crystal-lang
bew78 has quit [Ping timeout: 264 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <tekjar> Hi. Can someone pls explain why I'm getting Nil here?
<Papierkorb> tekjar, the cursor is still after the written data. There are no two cursors for reading and writing, there's only one for both. Use #rewind before reading it back
<FromGitter> <tekjar> Ohh. Thanks alot
<FromGitter> <tekjar> Papierkorb
<Papierkorb> Can I steal an object from the GC?
<FromGitter> <drosehn> The few times I've wanted a macro in crystal, I could get it to do what I needed it to do. But when someone else comes up with a macro-related question, it's clear that I haven't really learned how they work. (but I'm heading to dinner right now, so there's no need to help me out)
<FromGitter> <drosehn> The version of `macro something` that I posted earlier does what *I* thought that bew78 wanted to do, and makes sense to me. But I didn't understand asterite's comment that "you probably want {% ... %} here".
<FromGitter> <drosehn> So I tried "{% ... %}" in what I assume asterite meant, and that didn't work.
<Papierkorb> drosehn, do you know about templating languages like ERB or ECR?
<Papierkorb> drosehn, in ERB (iirc), <% x %> runs `x` but doesn't output its value - That's our {% x %}. <%= x %> outputs the value of `x`, that's our {{ x }}
Renich has joined #crystal-lang
<RX14> @spalladino you around?
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
theodorton has quit [Quit: theodorton]
pawnbox has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
<RX14> nevermind, replied to the email
pawnbox has quit [Ping timeout: 264 seconds]
Renich has quit [Ping timeout: 264 seconds]
<FromGitter> <drosehn> (I'm back from eating) I'm aware of templating languages like ERB, but I have never used them for anything.
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
Papierkorb has quit [Ping timeout: 264 seconds]
Papierkorb has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
akwiatkowski has quit [Ping timeout: 260 seconds]