« first day (2181 days earlier)      last day (2663 days later) » 

5:00 PM
Mathematica has the best loop syntax.
 
I think I still prefer an explicit return.
simply because its explicit
 
Anonymous
> Explicit is better than implicit.
2
 
that's naughty
 
I don't get it
 
5:02 PM
I think that you should be able to return explicitly, but if you omit it, return implicitly at the end anyway.
 
@KritixiLithos don't worry about it
 
Ah, it is the zen of python
or at least, a part of it
 
also, I learned yesterday that floating point calculations are somewhat difficult in most functional languages
 
@NathanMerrill how so?
 
because floating points depend on a number of global flags on the processor
and so setting those flags isn't pure
 
5:09 PM
what?
 
@NathanMerrill Really? What kind of flags?
 
I'm in CS right now, the guy next to me just complained that he's run out of variable names. Confused, I look over, and see: private int a,b,d,g,j,e,v;private double c,n,z,x,m;private String u,o,q,r;private int[]w;
 
@Pavel You found a golfer
 
@Pavel Suggest to use unicode characters XD
 
@Pavel he clearly need to start reusing variables
 
5:12 PM
@NathanMerrill Do they use soft floats then?
 
@quartata I'm not sure.
 
@NathanMerrill Can you make an example where something is dependent on these flags? (I never heard about that so far.)
 
I learned about it on D's language page
 
that's only 17 letters, he's still got 9 more
 
As a concession to practicality, a pure function can also:

read and write the floating point exception flags
read and write the floating point mode flags, as long as those flags are restored to their initial state upon function entry
 
5:14 PM
f h i k l p s t y
 
hmmm...apparently you can set the rounding direction
 
Also you can use _ as a variable in some languages
 
I did not find a golfer. private int counter;while (true){if(counter>10)break;o+=w[counter];}
 
@NathanMerrill Interesting.
 
I'm simultaneously laughing and dying inside...
 
5:17 PM
@Pavel welp
 
Also, new int[Integer.MAX_INT] because he hasn't heard of ArrayLists apparently and can't be bothered to resize arrays.
 
oh, if I haven't heard of ArrayLists, I'd do the same thing
 
@Pavel holy memory issues, batman
 
resizing arrays sounds like no fun
 
@Pavel W.H.A.T.
 
5:17 PM
ON AN OBJECT HE NEEDS SEVERAL HUNDRED OF BECAUSE OTEHR REASONS
Resizing arrays is easy. array=java.util.Arrays.copyOf(array,array.length+1);
 
you also have to do a size check
 
resizing an array in Perl is easy. $a[@a]=$x;
 
a furthermore, if you are appending to an array in a loop, that turns O(n) into O(n^2)
 
@NathanMerrill Found this post asking as far as I understand exactly about this, this is really interesting!
 
The max int is over 2 billion, at 4 bytes per int that's 8 MB per array
Seems legit
 
5:20 PM
Yes, but it takes several minutes just to load everything in.
 
And he has hundreds of arrays?
 
;-;
With the words "I have 8 gb of RAM, who cares"
brb, finding bleach
 
all of this floating point stuff makes me think that we're trying to force purity on an impure computer
 
0
Q: If statement-ception

Echo DotStart at 100. How many if statements will you have to use in order to add 1 every time the answer is divisible by 3, subtract 1 whenever the answer is divisible by 5, and divide by 2 when ever the answer is divisible by 2. If it applies to more than one of the statements, do all of the statements...

 
How is the polyglot challenge still going?!
It's mind boggling
 
5:33 PM
Every two weeks someone comes up to it with a defibrillator to prolong it's existence for a day before it dies again.
 
@BusinessCat this is PPCG. what did you expect?
 
in Pytek, Dec 19 '16 at 3:27, by quartata
func:for_reverse[sym:var](list:arr) {
  \for[x](\reversed(arr)) {
    \rewind(\block())
    \scope(\block()).var = x
    \yield[\block()]()
  }
}
We have a way to handle that planned ^
\block() returns a coroutine representing the code block.
Note that \scope is now called \shared
This is a little old
 
what does sym mean?
 
Obviously \break and \continue wouldn't be available but \return and \yield would have the same effect
@NathanMerrill Symbol
 
When it's reposted (per meta consensus that reposting is allowed), it should start with C.
#include <stdio.h>
int main() {
    printf("Hello World!");
    return 0;
}
 
5:43 PM
*wonders why my code isn't working* *realizes that I mistyped function as functiion*
 
@quartata so, is var a variable? Could I call var.getClass() or something?
 
@NathanMerrill var is a symbol: ruby-doc.org/core-2.2.0/Symbol.html
\shared (or \scope here since this is old) returns a dictionary of all variables with modifier shared: in the scope of a thread or coroutine
They can modified and new ones can be added. The latter is what's happening here
\rewind rewinds an iterator or coroutine
\yield yields into the coroutine
The coroutine is an optional argument -- if you do \yield() by itself it yields control to the parent coroutine which is how generators work
 
how does \block() work? does it magically grab the block of the function?
 
@NathanMerrill \block() is just a getter for the code block
You would call it like this:
 
right, but it isn't bound to anything
 
5:47 PM
It's a function
 
right, but its context specific
 
?
Not sure what you mean. It would just throw an error if there wasn't a block when parsed.
\for_reversed[sym:x]([1, 2, 3]) {
  \print(x);
}
 
\block() doesn't take any parameters, and returns a different thing depending on the function you are in
 
@NathanMerrill ...Yes.
 
therefore its magic, like _
 
5:48 PM
Yes.
Ruby does this too FWIW :P
We may figure out a way to add the code block to the parameter list in the future.
For now \block() seemed more flexible since it can return a list if there's multiple blocks.
 
right, and while I don't like it, I think the fact that you have _ means that \block() is fine IMO
aka, if you are going to make context-specific functions/variables, do it all the way
 
_ is only magic in the context of loops though
And even then if you're using _ in a loop you're lazy and want it
Hmm @El'endiaStarman what do you think of func:for_reversed[sym:var](list:a, {block})?
 
I'm trying my hand at the polyglot answer chain
and of all the languages my answer breaks
it's hexagony
 
@NathanMerrill Do you think that looks better?
 
I like that yeah
hmmm
some problems are "what if I put multiple blocks in the parameter list"
 
5:52 PM
@GabrielBenamy I'd think Hexagony is very easy to break.
 
@NathanMerrill That's fine.
 
"what if the block isn't the last thing in the parameter list"
 
I suppose that would be an error although it doesn't really matter
We have STDLIB functions that take more than one block:
in Pytek, Apr 4 '16 at 19:17, by quartata
\nestfor(x, y, z, ..., array) { foo } { bar } { baz } -> \for(x, array) { foo; \for(y, x) { bar; \for(z, y) { baz } } }
ewwww old for syntax haha
 
do you have var-args?
 
Yes.
*
 
5:54 PM
@Zgarb If I try and print a number that takes fewer bytes to print, it works
 
if so, can you var-args a block?
 
*{blocks} looks a little weird but I suppose that would work
 
I like that better than \block() not just because it isn't context specific, but it gives you the ability to require a fixed number of blocks, and lets you name them
 
@GabrielBenamy IIRC if the length of a Hexagony program exceeds a threshold, it's folded into a larger hexagon and quite probably everything breaks.
 
And gives an easy way of making them optional: func:x[{block}]()
 
5:56 PM
yep
which means that COW is just too big to fit
 
one more question, if I wanted to assign "_" to a \shared, what does that look like?
 
Chop it up into pieces of steak before fitting it
 
@NathanMerrill \shared(block)."_" = ...
 
oh, ok
 
Or \shared(block).(sym:_) = ...
Both are ugly as all hell, sorry.
 
5:59 PM
its not a common feature, so I don't care much about ugliness
but basically, it removes the magic from the \for function
which I think is a really good thing
 
I agree.
It irks me that in so many other languages syntax constructs like that can't be user-defined
That's why I went out of my way to think of a way to do it here. The fact that it ties beautifully into \shared (our most powerful reflection tool) and coroutines is a massive bonus.
Possibilities are almost endless :P
 
how does scoping work?
 
That's a good question. My intent was that shared: variables would be function scoped just to keep it safe but
 
like, it seems like \for is built-in, but say I built my \nathanfor, will people be calling merrilllib.\nathanfor?
 
It depends on how you organize your code.
If you just have it as a file you @include it would be \nathanfor. If it's in a namespace you @import then it would be \namespace_name.nathanfor
 
6:03 PM
the namespace is declared in the file with the function?
if so, it'd be great if you could do something like from x import y
 
namespace:namespace_name {
  func:nathanfor[]() {
    ...
  }
}
 
so you don't have to declare the namespace if you don't want to
 
@NathanMerrill That's what @import does
@include would be the equivalent of from x import *
 
ah ok
I missed that you were using two keywords import and include
 
They're preprocessor directives actually.
But yeah.
 
6:06 PM
and, I'm not sure how I'd improve it, but off the top of my head, I don't think I'd be able to tell you which does what
 
(Not like C's ugly preprocessor directives. This happens after parse but before it gets turned into an IR)
@NathanMerrill @import is if you want a specific namespace or object, @include gets you everything (like you copy-pasted the code into your file)
I know that the distinction isn't great but
I can't think of better names
 
yeah, neither can I
@quartata just wondering: you've replaced language syntax with functions. Is it possible to write your own preprocessor directives?
 
Yes, although obviously not yet.
 
It could be useful, but also seems like it could lead down a rabbithole mess
 
We want the parser and executor to be available so it would essentially just be like defining a function that operates on the parse tree.
 
6:16 PM
@BusinessCat mostly because it sometimes takes me almost two weeks to think of a language that will fit; it's had a burst of activity recently because it's now got long enough that the exponential growth allows some of the more verbose languages to fit, and it also hit some numbers (32, 33) that are particularly easy to generate in esolangs that are bad at arithmetic
 
@quartata how does that even work, though? Functions aren't runnable yet
 
@NathanMerrill It would be in another file that would be parsed first.
 
so, you run the entire process of compiling a single file at a time?
 
Perl has a BEGIN statement that runs as soon as it's parsed, and can affect the way the rest of the code is parsed
 
@ais523 Yes, it would be something like this.
 
6:19 PM
(actually, it's not just "can affect"; you can outright replace the parser if you want to)
 
you'd need to generate some sort of tree for file parse-order.
because I could use a preprocessor directive when defining another preprocessor directive
 
Hm...
 
Perl solves that by parsing the entire BEGIN before running any of it
 
so, you can't use preprocessor stuff in your BEGIN?
 
I'm not quite sure what happens with nested BEGIN but I assume it works the obvious way, of running the inner BEGIN immediately and allowing it to affect the way the outer BEGIN parses
 
6:32 PM
I can't believe vim doesn't have Go syntax highlighting by default.
 
@quartata if all language directives are functions, doesn't that impose some sort of necessary overhead to all directives?
I know that efficiency isn't a primary goal of Pytek
 
@NathanMerrill No, not all. \for is a regular syntax construct
But (don't tell the goat) since we can compile to C++ and we have @includec all Pytek STDLIB functions will be written in Pytek (where possible) and compiled to one big native shared object ;)
 
oh, so when parsing functions, you test to see if its a "built-in"?, and do your magic there?
 
@NathanMerrill Yeah. It can be a user defined function or one in our internal table. Those are written in Cython.
\for isn't actually a function even though it looks like one though.
\print is a good example of an internal function.
 
what do you call \for?
 
6:36 PM
It's an object node (pFor)
It's just a thing really.
It's parsed as a function but no function is really called. It handles itself.
 
lol
You basically have to check for "things" like \for, then for internal functions, then normal functions :P
 
is anyone here good with python?
 
I imagine most of us are
 
@NathanMerrill Well not really. \for is parsed as a function then turned into a subclass of pFunction when converted to an object
 
class Obj:
   @property
   def thing(self): return 1

   def is_property(string) -> boolean:
 
6:38 PM
So it's no more overhead than anything else
 
I want ^^
 
@quartata right, its not more overhead than a custom function, but compared to languages with a native for, it has the overhead of acting like a function
 
No not really actually
It's parsed like a function but it isn't a function
 
so can you first-class it?
@muddyfish why?
 
@NathanMerrill That would entail some sort of definition for for
I guess when I say "parsed like a function" I really mean "parsed like a function call"
We call that pFunction and an actual function definition pFunctionDef.
Yes we're weird.
 
6:42 PM
@NathanMerrill I'm trying to have a server being able to set certain variables in a client object
 
@quartata so if I wanted to pass a for loop as a first class function, (for whatever reason), that's not possible?
also, if you do have first class functions, how does that work with optional variables and {blocks}?
@muddyfish this is entirely too unspecific.
testing to see if something is a property sounds like an XY problem
 
@NathanMerrill Ohh nevermind I see what you mean.
Yeah currently that's not possible.
At least I don't think. Let me check.
 
    (state, value), = event.message.items()
    if isinstance(getattr(self, state, None), property):
        setattr(self, state, value)
 
Anonymous
@muddyfish this
 
Anonymous
If you need object property detection instead of class property detection, remove @classmethod
 
6:45 PM
@Mego thanks!
 
Anonymous
Actually it looks like you need @classmethod either way
 
Anonymous
So the same code works for class property detection and object property detection
 
@NathanMerrill Stop by the Pytek room if you have any more questions so that el'endia can see them too
 
link?
 
There you go
 

« first day (2181 days earlier)      last day (2663 days later) »