« first day (2361 days earlier)      last day (2483 days later) » 

6:00 AM
In a lexer, is it a better idea to return each token one at a time, or to return them all at once?
 
@Cowsquack If you are trying to write a compiler that can quickly parse large source files, one at a time, where the lexer and parser run in separate threads. But this is probably unnecessary for whatever you're doing - all at once should be okay
 
I need it for an esolang
so no compilers and stuff
 
Are you writing an interpreter then?
 
yes
 
I guess it depends
Let's say you're interpreting a file with some syntax errors
but the syntax errors are in "dead code" - AKA that code will never get run
do you want your interpreter to error on that syntax error, or run as long as it can?
There are valid reasons for choosing either way, but I suspect you'd probably prefer the latter
 
6:06 AM
@Cowsquack one at a time definitely
 
@HyperNeutrino @dzaima Minecraft crafting challenge is undeleted and running
 
@musicman523 D: But there is no valid reason for returning all at once
 
@ASCII-only If you want to support out-of-order access (e.g. function odd is defined on line 1 and calls function even which is defined on line 10) you would probably need to parse the whole thing before you can do that
 
@musicman523 yeah, the latter
 
@musicman523 well yeah? that's a job for the parse tree not the tokens
 
6:08 AM
Right but if that part of the code hasn't even been tokenized yet...
 
@musicman523 ... well you don't exactly execute tokenizer output right?
 
I'm saying that you at least need to know the function exists before you can call it
 
@musicman523 of course
but the lexer doesn't call it
 
...which means it must have been tokenized and parsed before execution begins
 
well of course
 
6:10 AM
that's the plan
 
but that doesn't mean the lexer needs to tokenize all at once
the parser can collect the output and turn it into a parse tree
 
@ASCII-only All of the tokenization needs to be done before execution begins
 
@musicman523 Of course. But parsing isn't execution
 
You can either 1) tokenize all the input, then 2) parse all the tokens
or thread it using a producer-consumer model
either way, all the tokenization and parsing occurs before execution begins
The python interpreter does not do this. The python interpreter will execute code as soon as it can, before it has even tokenized the rest
For example, if you try this code, the call to foo occurs before the garbage line is even parsed
 
@musicman523 yeah
 
6:14 AM
This is why, in python, you cannot call a function until you visit its definition
because not all the parsing occurs before execution starts
it does not
try my example
 
wait nvm
also how are you so sure, iirc python doesn't do that (i'm not aware of a language that does)
function hoisting isn't magic you get from parsing before executing
 
what do you mean
 
just because you have all the functions parsed doesn't mean they magically appear before they are defined
it's like doing:
x = 2
let x: Int
(pseudocode)
Oh btw JS + JQuery PPCG name -> id: s=>$.get(`//api.stackexchange.com/2.2/users?inname=${s}&site=codegolf`).then(‌​d=>alert(d.items.filter(u=>u.display_name==s).map(u=>u.user_id)))
 
Consider this code
 
@musicman523 what about it
 
6:19 AM
The only reason the call to is_even works is because is_odd is defined at this point
 
@musicman523 well obviously?
interpreted languages are not compiled, you know
 
if you move the call above the definition of is_odd, it won't work because is_odd isn't defined at that point
 
they don't have all functions defined before execution starts
 
@ASCII-only seems legit
 
@ASCII-only that is what I'm saying
Except that you could write an interpreter that parses the entire code before running
 
6:20 AM
@musicman523 ... doesn't mean they execute before they finish parsing
 
@ASCII-only If is_odd had already been parsed, it would have existed at execution time
 
@musicman523 ... seriously?
just because it's parsed doesn't mean it's in scope
 
Just like in my earlier example, if the garbage line had already been parsed before execution time, the message would never have been printed
 
python just goes through the parse tree sequentially (i.e. sanely)
 
@ASCII-only That would be an absolutely ridiculous amount of scopes to track, no reasonable interpreter would do this
 
6:22 AM
@musicman523 what do you mean
 
Think about it this way
let's say they do parse the entire file first
and then go back through for execution
 
@musicman523 i meant the function does not exist in global scope yet because it's been parsed but not executed (added to scope)
@musicman523 and then all functions are magically defined before execution?
 
@ASCII-only I don't think "execute" means what you think it means
Python is dynamically scoped, so is_even can see is_odd
but not during that particular call
because it wasn't defined until later
 
yeah?
the file is fully parsed though
 
the amount of information you would have to keep track of to do that scales horribly
there's no way python does it that way
 
6:25 AM
which way
 
parsing the entire file before beginning execution
 
why not
 
because the amount of information it would have to keep track of grows at a ridiculous rate
 
it would only be like a few kb of data at most (well say <100x the size of the file itself)
 
The amount of information it has to keep around grows exponentially with the number of definitions
it simply doesn't happen
it is a REPL
 
6:27 AM
4
A: How does python interpreter run the code line by line in the following code?

Serge BallestaIt depends on how you run the Python interpréter. If you give it a full source file, it will first parse the whole file and convert it to bytecode before execution any instruction. But if you feed it line by line, it will parse and execute the code bloc by bloc: python script.py : parse full fi...

@musicman523 ... well that's the REPL
 
"
I have read that the interpreter runs the code line by line and reports the error if any at the same time and stops the further execution. So in python, consider the file ex1.py,

print "Hello world"
12variable = 'bye'
print 12variable
Now according to the working of interpreter, the interpreter would run the first line i.e. it prints hello world first and then show the syntax error in the next line (line-by-line working). Hence the expected output is:

Hello world
12variable = 'bye'
^
SyntaxError: invalid syntax
 
otherwise explain this
 
That's not the output that happens...
 
6:29 AM
I swear to you
That's not what happened 20 minutes ago
You're clearly right
 
@musicman523 >_> <_< did you break python
 
But I swear that's not what happened earlier
I swear!!!
 
hah
i disabled one pylint message
> Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
and my code is now perfect 10/10
 
i don't want to see the pylint rating of charcoal
 
6:31 AM
Python == consfusion
 
@ASCII-only here lemme do it for you
 
@musicman523 because it's a valid program
@musicman523 not a syntax error
 
but there is a syntax error
 
@musicman523 that isn't a syntax error
 
That is definitely a syntax error
 
6:32 AM
that's a statement that does nothing apart from access that (undeclared) variable
 
oh poopoo
it's a NameError not a SyntaxError
alright well I clearly need to sleep lmao
good night everyone
 
duck?
 
idk if it actually works in Charcoal though should probably add tests
@Cowsquack well not really a duck more a value that acts as falsy to all types i guess?
 
6:36 AM
ok interesting
 
so whatever you operate on it with it just returns the other item, it acts kind of like the identity i guess?
 
mm ok
i wonder if arithmetic operations should do anything with Sequence objects
hey would anybody expect an object representing an OEIS sequence to perform any arithmetic operations?
 
oh no what are out and out2 doing there
 
like would you expect to be able to do something like Sequence(4) + Sequence(0)
 
@totallyhuman yes :P
@totallyhuman is this a fictional oeis lang
 
6:40 AM
no i wish
i do not want to deal with scraping the whole oeis
 
@totallyhuman well that isn't enough you'd need a function for every sequence
 
it's a python library
@ASCII-only yes, scrape and parse the formulae or something
 
@totallyhuman yeah that won't always exist though
 
but that's incredibly difficult
mm that too
i still am pissed that i had to add a dependency to parse a frickin timestamp
 
just ran pylint3 on charcoal, it errored D:
@totallyhuman datetime.strptime didn't work?
 
6:46 AM
no
there's no suitable format string ;-;
 
why does running pylint3 on Charcoal have to be so hard
 
375
Q: How to parse an ISO 8601-formatted date?

Alexander ArtemenkoI need to parse RFC 3339 strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type. I have found strptime in the Python standard library, but it is not very convenient. What is the best way to do this?

 
98
A: How to parse an ISO 8601-formatted date?

sethbcNote in Python 2.6+ and Py3K, the %f character catches microseconds. >>> datetime.datetime.strptime("2008-09-03T20:56:35.450686Z", "%Y-%m-%dT%H:%M:%S.%fZ") See issue here

 
1991-04-30T03:00:00-04:00
the issue is not microseconds
it's the time zone offset
 
@totallyhuman parse re.sub(":(\d+)$", "", string) or something?
a bit hacky but kinda works
 
6:58 AM
actually...
i could probably do a similar thing while not completely ignoring the tz
re.sub(':(\d+)$', r'\1', thingy)
then parse it with %z
datetime is still painful though
 
7:20 AM
ppcg is on programmerhumor :O
 
Anonymous
@MartinEnder I'm glad you enjoyed it. I'm not super pleased about needing multiple playthroughs for all the story either, but Bastion was the same way. The item for the trial that gave backstory on Rucks only was available in NG+.
 
also datetime is impossible
 
@Mego oh okay, didn't remember that
 
7:49 AM
3
Q: Find the Missing Letter

AmorrisGuidelines Task Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array (lists in some languages). Rules This is code golf so the shortest answer in bytes wins! You will always get an valid array There will always be ...

 
8:04 AM
morning chappos
 
hi
it's 4:04 am for me
time not found
 
silly yanks
 
hey does anybody know if taking a bytestring for input is allowed (in python)
 
8:39 AM
0
Q: Double-time is not double time

MayubeBased on this challenge. In the rhythm game osu!, the difficulty modifier "Double-time" actually only increases the speed by 50%. Your task, is to write a program that outputs a positive even integer (higher than 0), and when each character in your source code is duplicated, it should output th...

 
well
guess I'm not making any of that koth then
 
why
 
because I procrastinate
 
what was the idea behind your koth anyways?
 
fastest code spaceships
with melee
 
8:50 AM
CMC: given a positive integer, output whether it is the result of another positive integer added to its reverse
 
I might borrow your idea
 
bump them out of the area
@Cowsquack noooooooo
 
2 = 1+1, 4=2+2, ..., 11 = 10+1, ..., 121 = 56+65, ...
 
its mine
 
okay sorry
 
8:51 AM
ok but I would appreciate some help
maybe
 
I can help
 
Hi there
 
the idea seems interesting
 
9:09 AM
Hi
 
hmm, I can't find a 3 byte braingolf answer to my double-time challenge. I think braingolf needs a 1 byte "increment by 1" operator
 
Hmm, I think my challenge is on HNQ, because it got a bit out of control in the past 6 hours :p
 
I'm just happy braingolf had the perfect tool for the job for your challenge :P
I think my answer to your challenge is actually my most upvoted answer so far
it is, 2 higher than my C# answer to one of my own challenges
 
@Mayube Nice, my most upvoted one was on that challenge with XKCD by BetaDecay, I got ~90 upvotes there, and another one was It was just a bug, by Kevin, where I got ~60
 
:( mine's only at 14
 
9:20 AM
@Mayube My third most upvoted answer has 13, and then I have 2/3 with 12.
I am quite proud of this one, though, which only got 12 :(
 
Looks like nobody wanted to go through the effort of answering this in braingolf for 150 rep
if the bounty expires without being awarded, do I get the rep back?
 
No, it is automatically awarded to the answer with the most upvotes since you placed the bounty, I think. You never get your rep back for bounties
 
Time to learn Braingolf, I guess...
my bot could use some rep
 
so if nobody does it in braingolf within the next 24 hours, the Python 2 answer gets +150 rep
wait most upvotes since the bounty was placed? what if no answers were upvoted?
 
If the python answer has ~170 bytes, braingolf woould be loooooong
@Mayube IDK,
Sorry, with the most upvotes in general (I think)
 
9:24 AM
@Mr.Xcoder braingolf usually outgolfs python
 
@Mayube ಠ_ಠ
Ok, I must work on Cthulhu now.
 
@Mr.Xcoder it may not be the golfiest of golf languages, but it's still golfy
 
Is there a meta-post somewhere about why I can't invent a new language, HQ9+-style, for any given problem?
 
But I will stay around to request feedback
@Flonk Default Loopholes
 
9:27 AM
@Flonk This answer, to be more specific
 
ninja'd
 
@Mayube You only linked to the question @Mayube
And also:
 
no I mean you ninja'd me, i was just about to link the answer
 
@Mayube ಠ_ಠ
yesterday, by HyperNeutrino
Jun 23 at 12:27, by Erik the Outgolfer
please, "ninja'd" should be restricted to when you actually post the message a split second later than somebody else posting the same message, and then you are the one who is ninja'd
@Mayube Do you really think my challenge was too trivial?
 
Double the source double the output? Not at all
 
9:30 AM
@Mayube Ok
 
I think it's a great challenge and gave it a well-deserved upvote
 
I imagine this will be far less trivial than the original challenge, that's why I asked
@Mayube Thanks :p
 
that was mostly as a counter-argument to potential dupe-hammers
 
@Mayube Ah, I see
I like your title
 
It's just always amused me that osu!'s double-time setting is only 1.5 times speed
@JanDvorak if you're actually planning to attempt for the bounty, let me know if you have any questions about braingolf stuff
 
9:35 AM
Huh, that's a weird place to draw the line.
Would a single-letter command that returns a range from -abs(x) to abs(x) be considered too specific?
 
I found the best character possible that will check if a number is a Fibonacci number: .
And for generating the nth Fib number
 
@ATaco the wall looks curved when you're standing next to it
 
Yeah I know, still haven't gotten around to fixing that.
 
9:52 AM
Do you think it is enough for Cthulhu if it can generate the 500000th Fibonacci number?
I think it is fine
You know, that is a large number.
 
CMC: help me come up with a good language paradigm for my koth's language
 
@DestructibleLemon KOTH Oriented ?
 
it is the language the bots in my koth will be programmed with
I need to be able to measure cycles easily
 
@DestructibleLemon OOP?
Imperative?
 
ok but I mean the syntax and stuff
 
9:58 AM
@DestructibleLemon Use what you like most
Python is always a good choice
 
ok thanks but I'm trying to come up with ideas
which is the idea
@Mr.Xcoder not so easy really
the idea is the lang is supposed to be simple, and implemented so I can count cycles
 
@DestructibleLemon Depends on your preferences
 

« first day (2361 days earlier)      last day (2483 days later) »