« first day (3994 days earlier)      last day (955 days later) » 

4:34 AM
@Skillmon you're welcome ;-)!
 
 
1 hour later…
5:34 AM
@DavidCarlisle If there wasn't the pineapple pizza
 
6:31 AM
user image
6
 
6:52 AM
@UlrikeFischer your monitor seems to be distorting circular badges
 
7:26 AM
@DavidCarlisle much nicer shape, unless you prefer pizza for dinner.
 
@UlrikeFischer but congratulations, you should claim your share of the Nobel prize for chemistry palindromes that got announced yesterday.
3
 
8:32 AM
@mickep ooh
@DavidCarlisle oi
@StefanKottwitz oh no
 
@PauloCereda b
 
@DavidCarlisle oh no
 
 
3 hours later…
11:23 AM
Hi folks, I have a simple Lua question. I thought I'd ask here. Otherwise I could try StackOverflow, though I am sure it has been asked somewhere already.
function foobar()
end
print(foobar())

if foobar() ~= nil then
   print("FOOBAR DOES NOT RETURN NIL")
end
The "FOOBAR DOES NOT RETURN NIL" is not printed. So am I to conclude that foobar is returning nil? This does not appear to be true. As is clear, foobar is returning nothing.
 
@FaheemMitha and thus nothing isn't nil :)
 
@PauloCereda If it isn't, then the message should be printed. It isn't.
 
@FaheemMitha well, why are you checking the return of a function if your function clearly does not return anything? Your code simply does not make sense to me.
 
@PauloCereda It's just an example. Consider a function that returns something sometimes and nothing other times.
 
@FaheemMitha it's a terrible, terrible design
 
11:32 AM
@PauloCereda It's an example. Not actual code.
 
@FaheemMitha okay. :) It's a terrible, terrible example :)
 
@PauloCereda Thank you for your feedback.
 
@FaheemMitha @Marcel might have a better understanding of this, but even the manual has some confusion on what a function with no return should "return in practice".
> foobar() == nil
true
@FaheemMitha my take is that the result of the last expression in the function is returned, which does not exist, and thus nil is returned.
 
@PauloCereda Perhaps so. I can't find any discussion of this, but searching for things related to "nil" and friends is hard. Maybe I'll ask a question on SO just for clarity.
The context is posix.stat, which returns nothing if there is no match.
 
> function foo() end ; function bar() return nil end
> foo() == bar()
true
 
11:37 AM
There is no documentation of this to speak of, but I checked the source code. Or what I think is the source code.
 
At least semantically they behave the same.
 
@FaheemMitha I don't think there is a value "nothing" so a function can not return that, it returns nil if nothing else specified
 
Though if the function returns nil then printing it should produce nil, which it doesn't.
It prints nothing.
function foobar()
end
print(string.format("RETURN VALUE OF FOOBAR IS %s", foobar()))
 
> function f() end
> f
function: 0x5646a3ef5760
> f()
> a = f()
> type(a)
nil
 
That throws an error.
OTOH,
print(string.format("RETURN VALUE OF FOOBAR IS %s", nil))
happily prints nil.
 
11:42 AM
actutally the manual says Results are returned using the return statement (see §3.3.4). If control reaches the end of a function without encountering a return statement, then the function returns with no results. so no return doesn't return nil but if teh function is used as an expression then such a thing is equal to nil, I wonder if that's documented..
 
@DavidCarlisle Can you give a link? I'm not sure what §3.3.4 is.
 
@DavidCarlisle Thank you.
 
@DavidCarlisle it's like it's not nil per se, but once the function is treated as an expression, it returns nil for practical purposes?
@DavidCarlisle what would you expect from something developed by Brazilians? :)
@PhelypeOleinik ^^
 
there is discussion about this here
2
A: Returning 'nil' from a Lua function in C vs returning 0 values

Egor Skriptunoff(This is not an answer, just an opinion about the subject) As for me, this artifical difference between nil and no value is inconsistent and rather annoying. local function f1() return nil end local function f0() end local v1 = f1() -- OK, assigns nil print(type(f1())) -- OK, prints 'nil...

 
11:45 AM
@PauloCereda Works surprisingly well :P
 
@PhelypeOleinik ooh :)
 
@DavidCarlisle Looking. Thank you.
 
@FaheemMitha the nil behaviour is documented lua.org/pil/5.1.html " If a function has no results, or not as many results as we need, Lua produces nils: " so foo() returns nothing but in foo()==nil a nil is "produced" so the construct returns true
 
@DavidCarlisle ooh expression requirements :)
 
@PauloCereda You might think, but especially in LuaTeX it sometimes does make a difference. E.g. the node library sometimes enforces the number of arguments, so if the last parameter is nil you can't replace it with a missing value. Other functions use e.g. the last argument instead of e.g. the third one, so again it makes a difference if the last argument is nil (and therefore counted) or doesn't exists.
But as long as the function call is not the last thing in an argument list or a return statement, there shouldn't be a difference.
 
12:09 PM
@DavidCarlisle Is the print behavior documented as well?
As in
29 mins ago, by Faheem Mitha
function foobar()
end
print(string.format("RETURN VALUE OF FOOBAR IS %s", foobar()))
Which in combination with the previous behavior discussed, is a little disconcerting.
So in the context of this print statement it's not returning a nil, but for the comparison operators it is?
 
@FaheemMitha print prints each argument it receives. So if it's nil, it prints nil, but if you don't pass any argument (since the function doesn't return anything) then it prints nothing. That directly follows from the official documentation. But in your case it sounds like you are actually wondering about format.
@FaheemMitha format has a variable number of arguments, so if you use a function in the last position which doesn't return anything than nothing is passed as argument. So your code is the same as foobar() print(string.format("RETURN VALUE OF FOOBAR IS %s")) . Lua warns about that since it expects format to receive the right number of arguments.
@FaheemMitha You can always put parens around your function to avoid that: print(string.format("RETURN VALUE OF FOOBAR IS %s", (foobar())))
 
@MarcelKrüger cool, thanks!
 
12:28 PM
@MarcelKrüger Well, it's confusing, because it looks like foo() returns nil. But it seems that that the nil return value is actually "constructed" in some fashion when assignments are made, or when its used in an expression.
Here is someone complaining about the same thing
2
A: Returning 'nil' from a Lua function in C vs returning 0 values

Egor Skriptunoff(This is not an answer, just an opinion about the subject) As for me, this artifical difference between nil and no value is inconsistent and rather annoying. local function f1() return nil end local function f0() end local v1 = f1() -- OK, assigns nil print(type(f1())) -- OK, prints 'nil...

No, actually not the same thing. Never mind.
Especially in the comparison case it's confusing, because there does not appear to be any assignment of the function value there.
The return value, that is.
@MarcelKrüger I'm not clear what the parens do.
 
@FaheemMitha There are IIRC two cases where Lua uses parens: After a function name to define the arguments or to pass them (which isn't the case here since there is nothing callable before them) or around an expression to form a new expression with the same value (used to change operator precedence). Therefore in this case the second case is used, which expects an expression inside. Therefore the empty list appears in an expression and gets converted to nil.
 
56 mins ago, by Paulo Cereda
@DavidCarlisle what would you expect from something developed by Brazilians? :)
:)
 
12:45 PM
Not sure what Brazil has to do with it.
@MarcelKrüger Actually, if the function returns multiple values, it will just restrict to the first value if brackets are applied. So it has a second effect if used with a function.
 
12:59 PM
@FaheemMitha check who created lua.
 
1:16 PM
@FaheemMitha That's not a second effect but exactly the same one. Whenever Lua needs n values and m are provided, it will discard the last values if m>n and will fill up with nil if n>m. In an expression (e.g. due to parens), one value is needed, so n=1. A function without return values provides 0 values, so m is zero.
 
@UlrikeFischer l-ooh-a
@MarcelKrüger ooh let's unpack
 
1:27 PM
@UlrikeFischer Criador da lua, das estrelas e de toda a criação?
 
@JosephWright et al. During the l3build change I noticed that the cp function applied to directories does not do the right thing on UNIX like systems. Fixing this while still using the cp command does not really seem possible using only POSIX functionality.
We could solve this by using a GNU extension which probably wouldn't work on BSD systems (and OSX) or with a BSD extension which isn't supporte by GNU (and therefore most Linuxes) or we could use rsync instead (but I don't know if that's installed everywhere).
 
Apparently I have a cuneiform character named after me. Who knew?
5
 
@MarcelKrüger what is the "right thing" (that cp -r isn't) ? symlink stuff?
@MarcelKrüger zip the source and unzip at the target? (since you have zip built in already)
 
@DavidCarlisle If a and b are directories and b exists, cp -r creates a directory b/a and copies stuff there while it copies directly into b is it does not exists. Since we often precreate the directories, this leads to very inconsistent behavior.
 
@MarcelKrüger oh well yes but you can make the target first (or delete the target first) so you know which case you are in
 
1:36 PM
@DavidCarlisle Creating the target first is complicated if we explicitly want to copy into an existing directory (which might contain existing data). Also we can't delete a directory which isn't necessarily empty.
 
@MarcelKrüger thats true of files as well, not just cp -r if you go cp myfile /tmp/zzz then if zzz exists and is a directory you get /tmp/zzz/myfile otherwise you get /tmp/zzz being a copy of myfile
@MarcelKrüger yes but you can do a create if doesn't exist easily enough can't you?
@AlanMunn I tried that with luatex but you are reported as a missing character. I hope you are OK?
 
@DavidCarlisle Yes, but we want the other case. If we have a directory a and want to copy it's content into b, then we might know which case we are in but that only means that we know the files will end up in the wrong place.
@DavidCarlisle Well --no-target-directory would fix that too.
 
@MarcelKrüger isn't that cp -r a/* b after checking b exists (and possibly .* as well)
 
@DavidCarlisle :) I appear to be.
 
@DavidCarlisle That might work, but we'll have to check how this interacts with . and ... (It seems to depend on the shell if .* matches . and .., but especially copying .. might be problematic.) That makes me wonder if cp -r a/. b might do the right thing in all cases.
 
 
1 hour later…
3:07 PM
@Skillmon Not a big deal. I deleted that answer because it was wrong, not because it was downvoted—I wrote it on my phone away from a computer and realized it was wrong as I walked back home & deleted it as soon as I could.
 
@PauloCereda Happy Christmas! :D
 
@mickep Happy Christmas! <3
@mickep I blame the postal service :)
 
@PauloCereda Was it quick or slow?
 
@mickep too efficient :)
 
3:27 PM
@MarcelKrüger Perhaps you should be writing Lua documentation. And is a value needed in a comparison expression? It seems comparing to nothing would be legitimate.
 
@MarcelKrüger traditionally in Unix the trick was to use a tar -c -| tar xp - pipe to avoid problems. But my unix tricks skill is a bit old and with a lot of rust...
 
@MarcelKrüger The cp() function was never intended to copy directories, only files - think Windows copy rather than xcopy
 
3:51 PM
@FaheemMitha == is a function of two arguments, just written infix, so it will require two values.
@Rmano yes the logical ancestor of the zip/unzip I suggested above:-)
 
4:40 PM
@DonHosek I just wanted to clarify because of my comment :)
 
yo'
4:51 PM
is the Facebook ecosystem down again? :D
update: seems to be down only on my home network...
 
5:16 PM
@JosephWright Initially that was probably true, but 5c435fb very directly extended it towards directories.
 
@MarcelKrüger Ah, I'd forgotten about that
 
@JosephWright Anyway, I was probably mistaken about how cp was supposed to work, now I think that it's just weird and not broken.
 
@MarcelKrüger Is that some Lua cp?
 
@MarcelKrüger Feel free to tidy up: perhaps replace with something that's explicitly meant to be xcopy()?
 
@JosephWright Anyway the direct-copy branch has some first code which uses it to copy directories as is. Basically used as tdsdirs = { sourcedir = 'tex' } to copy sourcedir into $TEXMF-WHATEVER/tex.
(I know that the name of the variable needs work...)
 
5:23 PM
@MarcelKrüger I'll try it out later: just leaving work
 
How to type this?
 
@JosephWright what is aip and aps in biblatex-phys?
 
5:53 PM
@Wolgwang is don't an answer? :-)
otherwise some combination of \sqrt and \reflectbox \sqrt and some spacing
 
@UlrikeFischer American Institute of Physics, American Physics Society
 
@DavidCarlisle :-)
 
@JosephWright ah ok. Are the guidelines for journals or more generally?
 
@UlrikeFischer Journals - I can't speak directly for physics, but in chemistry I'd always say 'follow a journal style'
 
\documentclass{article}

\usepackage{amsmath,graphicx}

\begin{document}
\[
A=\sqrt{\frac{a+b}{2}}\!\reflectbox{$\displaystyle\sqrt{\vphantom{\frac{a+b}{2}}\,}$}
\]
\end{document}
 
6:14 PM
@DavidCarlisle "don't do it" things are the quickest to implement ;-)
 
@DavidCarlisle Thanks :)
 
@Wolgwang my first answer was better
 
XD
 
@Wolgwang what does it mean?
 
6:30 PM
@DavidCarlisle It is most probably a typo from a very old book. i.stack.imgur.com/80PHJ.png
I was wondering if it is possible to type it in LaTeX.
 
@Wolgwang oh it's not even square root the first bit means A=\frac{a+b}/2 :-) so it's just decoration:-)
 
Hehe
 
@AlanMunn -- When the powers that be get around to trashing the imgur avatars, you can use this as yours.
 
@PauloCereda Oh, quick ducks swimming over the Atlantic. In any case, it made my day! :)
 
@JosephWright and @UlrikeFischer -- More properly, APS = American Physical Society.
 
6:43 PM
@mickep ooh
 
@barbarabeeton I wasn't 100% sure - I'd not checked as they are always just called APS
 
7:06 PM
@barbarabeeton thanks. corrected.
 

« first day (3994 days earlier)      last day (955 days later) »