« first day (1939 days earlier)      last day (2903 days later) » 

3:02 AM
I think this is probably my favorite xkcd
I always lose it at "a finite but arbitrarily large number of wishes"
 
^ I'd like one of these in my yard (and I'd like a yard while I'm at it)
 
3:24 AM
how do i upates my github fork
@Quill where is adynata interpretetiting code
 
@Downgoat I don't think you can. I always just destroy and refork.
 
@quartata ._.
nvm, git pull upstream works
@QPaysTaxes :D
:(
@QPaysTaxes OH YES, BRB DOING THAT
(but in a new file)
what does this part do?:
if sys.version_info[0] < 3:
also, does r"\n" match a literal newline or \n?
ok
 
3:47 AM
@FryAmTheEggman s+:R"O.*<|>.*O"0Q:R"O.*\^|v.*O"0CQ
A solution to a challenge
 
@QPaysTaxes what does this bit of code do (in the escape function): lambda s: escapes.get(s.group(0), s.group(1))
but what does escapes.get(s.group(0), s.group(1)) this bit do?
 
@Downgoat wat
The very shitty language I am/was working on
lately I've got a massive amount of issues being opened in my SE related code, so I've had no time to whore it around the room
yeah, like userscripts, chat bots, etc
else:
    str = str
    input = input
seems a little redundant <_<
 
4:06 AM
But
wait a sec, it is
 
4:20 AM
@QPaysTaxes what license is Concaten under?
 
last challenge was 10 hours ago
what is this people
get to work!
more challenges!
NO EXCUSES
 
@orlp but im a goat, i am busy eating tin cans
 
@Downgoat since your goat is upside down you must be from australia - are you gary?
 
@orlp ? I am from california
 
@orlp what about south america and africa
 
4:30 AM
> valfonria
 
it's next door to narnia
 
@Quill south america and africa touch the equator so it's not completely on the southern ehemisipher
 
....
 
i make good commit messages
 
I think I might start hanging out in Discord a bit more
 
4:32 AM
hey, I'm debating making the clone() method in my language take an integer parameter that determines the number of levels deep
 
@Quill Discord?
 
clone(list, 1) would copy the structure, but clone(list, 2) would copy the objects in the list as well
 
@NathanMerrill it should completely clone an object. An integer parameter doesn't make sense to me
 
what do you mean by "completely"
should cloning a list clone the objects as well?
 
@NathanMerrill recursive, infinite levels
 
4:34 AM
that's not what you want in most cases
 
why not?
 
copying a new structure without cloning the objects
for example
 
if I wanted to clone a class, which has a property which is equal to another class, and so on, would it just truncate properties that aren't primitives?
 
List<List<Object>>
lets say I wanted to clone the above, but not the actual objects
I could do clone(list2d, 2)
 
@NathanMerrill I guess if you'd think an integer parameter would be helpful, it should be optional.
 
4:36 AM
good coding music
 
@Quill thanks for not being a rickroll
 
Depends
 
@Downgoat of course, set to 1
 
Normally clone() implementations do a shallow (1-depth) clone
 
Question about cheddar: if a variable is operated upon, should it loose its reference?
 
4:38 AM
@Downgoat ?
 
you don't really need explicit references if you're not making a stack based language or one with limited space
 
@Downgoat halp do you know any JS application things other than Ace Editor?
 
application things?
 
basically if I have a variable and I reference it (e.g. by calling avocad), it is put on the call stack, when it is put on the call stack, it get's a special property saying where it originated from (the variable name), if an operator modifies the item, should it loose that special property?
@MarsUltor what is wrong with ace?
 
Nothing, just that it's only one thing
 
4:40 AM
another question. I want to make a constant modifier for my class, which basically ensures that any modifying function clones the object before modifying it
 
@Downgoat the value has to get reassigned somewhere
 
but what if I have a constant Queue
and I call "pop"
 
@MarsUltor codemirror maybe?
 
what gets returned?
 
though ace is the best by a longshot
 
4:41 AM
I mean things other than a text editor
 
@Quill what do you mean by that?
 
var a = 4;
a + 1 // the value is returned and goes nowhere
a = a + 2; // the value is reassigned
 
@MarsUltor like tinymce
 
either 1. I don't allow returning values on functions that modify for constant classes, 2. I return a tuple, or 3. I return the new value, but don't have a reference to the new queue
 
@Quill yeah, so the behavior of ++ would get the reference and update it, but after an operator is used on a variable, it should loose it's refernce?
e.g. (a++)++ shouldn't work?
 
4:43 AM
sorry, see update
255
A: Declare a Const Array

Cody GrayYes, but you need to declare it readonly instead of const: public static readonly string[] Titles = { "German", "Spanish", "Corrects", "Wrongs" }; The reason is that const can only be applied to a field whose value is known at compile-time. The array initializer you've shown is not a constant ...

@NathanMerrill ^ I like how C# does it
 
my definition of constant is a bit different
maybe I'll name it differently
Integer is constant
because if I do a = 1, b = a, a++, b returns 1
 
That's C#'s struct
returns a new instance every time, except for integer decrement/increment
 
except?
why?
 
I mean
uh wait
ints are primitives
 
lol
 
4:48 AM
structs do return a new instance every time though
probably what you want for constant non-primitives
 
anyways, what if a struct has a function that modifies itself and returns a value?
is the newly-modified struct inaccessible?
 
Pretty sure structs can't change their values
any operator + assignement (e.g. +=) is actually a create + set
 
I can't find any documentation on that
 
0
Q: Output the alphabet using the alphabet

DerpfacePythonThe title is pretty self-explanatory, isn't it? Your task is to output the alphabet (the string "abcdefghijklmnopqrstuvwxyz") to STDOUT, using each and every letter of the lowercase alphabet in your program once and only once. Rules: Only standard letters of the alphabet from ASCII count as l...

 
@KennyLau cat is not a programming language, but turing completeness is not required
 
4:55 AM
it is required
 
Whoops
 
no its not
 
43
A: What are programming languages?

Peter TaylorMy previous answer was criticised for not drawing a line in a sand, so following some discussion on chat I propose a line. Executive Summary A purported programming language should be accepted as such if and only if it is capable of addition of natural numbers and primality testing of natural n...

 
It's just that any assignment deep copies
 
4:55 AM
hmmm...it appears that assignment copies
not modification
for structs
 
yeah
 
@orlp well, use your lang to demonstrate that 17 is a prime
 
makes a lot more sense
 
1 min ago, by orlp
@KennyLau cat is not a programming language, but turing completeness is not required
 
therefore, if you have a function that modifies the struct
it'll modify it, just like any other function
 
4:56 AM
@orlp Primality testing is though
Plus basic arithmetic
 
which part of "cat is not a programming language" is unclear?
 
meow
 
is there a term for "copy on assignment"?
 
@orlp @KennyLau It's a poor question anyway. Not worth arguing about
 
@NathanMerrill cow; copy on write
or do you mean the opposite?
@HelkaHomba I think it's an interesting challenge for python for example
 
4:58 AM
I mean that a = MyObj(), b = a, b is a cloned object
 
 
@NathanMerrill value semantics
as opposed to reference semantics
Python uses reference semantics
C uses value semantics
 
right, but if it is modifier for a class, what would that be?
 
could you rephrase?
'modifier for a class'?
 
@Quill @cat iz overflowing r bufferz? D:
 
5:00 AM
aka, by default, everything is copy by reference, but you can declare certain classes to by copy by value
(technically, variables will still be references, but it'll call the clone method before copying)
 
@NathanMerrill you declare those classes to have value semantics
is this for a programming language your designing?
 
I can tell you that this will probably cause a lot of confusion
and is probably not the way to go
 
hmmm? Why do you think so?
for example, Integers and Strings work this way.
 
because now when I see a = b somewhere I need to know what a and b are
@NathanMerrill in Python?
or
 
5:02 AM
yes
 
because that's not how they work
they are immutable
but still have reference semantics
 
functionally, they are identical. a = 4; b = a; a++
b is still 4
same thing with strings
 
@NathanMerrill python doesn't have a++
 
oh right
a += 1
 
that's shorthand for a = a + 1
which makes a new object
so b is left unchanged because a is now a reference to a new object
 
5:04 AM
right, and that's literally what I'm doing
 
then you should say that integer and string are immutable
 
@orlp how are strings immutable if you can do a = "foo"; a = 123?
 
@Downgoat because a is a nametag
 
oh, so the value within is the immutable thing?
 
when I write a = "foo", now a is a name for some literal string
 
5:05 AM
Yes
 
if I now do b = a, then id(b) = id(a)
 
whether or not the copy happens on assignment or on modification makes little difference IMO
 
@NathanMerrill the thing is
in Python
= never copies
 
right, just that a+1 returns a new reference
 
a = ... means "a is now a name for ..."
 
5:07 AM
var a = 'foo', b = a, a += 'bar'
a
"foobar"
b
"foo"
 
@orlp hard thing doing it in python
 
If strings were mutable, "foo" would become "foobar" in both variables since the actual string changes
 
python does copy on modification
 
@MarsUltor again, a += ... is shorthand for a = a + ..., and never modifies whatever a pointed to
@NathanMerrill it does not
 
aka, a + 1 creates a new variable with the value of the two added together
 
5:08 AM
it creates a new value
then a points to that value
 
its an object
right
a new object is being made
 
@El'endiaStarman have you gotten to assignment in Pytek?
 
yes
 
therefore, maybe "copy" is the wrong word, but it is effectively copy on modification
 
no, it's not a copy on modification
a copy implies a new memory location
 
5:09 AM
well, if there is a new object
there's a new memory location
 
then it means the copy already happened
not 'on modification'
keep in mind
strings and integers are never modified
5 + 3 modifies neither 5 nor 3
 
what actually happens in the backend is irrelevant
 
it's just a function that returns a new value based on 5 and 3
 
a + 1 could copy a, then modify the copy to be plus 1
 
if a = [1, 5, 2], then a[1] = 31 means a was modified
@NathanMerrill but that's a perversion, that's not how it works
modification of an object is well-defined in Python
class A: pass; a = A()
a.x = 5 <-- this is modification
 
5:13 AM
I know that it isn't actually copying
 
I've concluded that it is impossible in python
 
@KennyLau what is?
 
that challenge
 
anyways, are there functional differences between "clone on assignment" vs "clone on modification"
 
@NathanMerrill yes
 
5:14 AM
aka, pass by value vs immutable
@orlp beyond what happens behind the scenes?
 
clone on modification is not immutable
get that out of your head
copy on write is well-defined, and something different
for example, some C++ implementations use copy-on-write for strings
 
I know what happens is different, but the two are functionally identical
 
they are not
let's say I do this in Python
a = [1, 2, 3]
b = a[:] # copy
b[1] = 42
now a is [1, 2, 3], and b is [1, 42, 3]
 
right
 
normally, the data inside a is copied on the line that says copy
but that's not needed, until b is modified
now some (implementations of) languages, employ copy on write
that means that the copy doesn't actually happen until it's necessary
so in the example above, no copy would happen until b[1] = 42
Copy-on-write (sometimes referred to as "COW"), sometimes referred to as implicit sharing, is an optimization strategy used in computer programming. Copy-on-write stems from the understanding that when multiple separate tasks use initially identical copies of some information (i.e., data stored in computer memory or disk storage), treating it as local data, each task working on its own "copy of the data", that they may occasionally need to modify, then it is not necessary to immediately create separate copies of that information for each task. Instead they can all be given pointers to the same...
 
5:17 AM
right, but lets say you can't see what happens behind the scenes
they are functionally identical
 
no they are not
a + 1 doesn't copy anything
get that out of your head
 
I know it doesn't, but if it did, you couldn't tell the difference
seriously, lets say that integers were copy on write. give me two sections of python code that would execute differently
meaning, the return value is different
 
integers can't be copy on write
since you can't write them
 
they could be, if I wrote my own implementation of python
 
how would you write integers?
 
5:21 AM
class MyInt:
    def __init__(self, val):
        self.val = val
now, lets say there are two possible add functions
 
add is not a copy operation
can we get over this?
 
def add(self, other):
     return MyInt(self.val + other)
def add(self, other):
      new_int = MyInt(self.val)
      new_int.val += other
      return new_int
while the first is clearly optimal
 
they are identical
but what about that?
neither are copy operations or have any relevance to copy on write
 
I'm using the new_int as a copy operation
 
A constructor pretty much creates a copy
 
5:24 AM
new_int = MyInt(self.val) here you've already copied
so neither is copy on write
 
right, I copy and write
I don't know how that isn't "copy on write"
 
copy on write means that no copy happens until a write happens
 
do you write to the old copy?
because I'm clearly writing to the new copy
 
@NathanMerrill copy on write is rather complicated
class COWList:
    def __init__(self, l):
        self.l = l

    def append(self, val):
        self.l.append(val)

    def set_item(self, idx, val):
        self.l[idx] = val

    def get_item(self, idx):
        return self.l[idx]

    def clone(self):
        return COWList(self.l[:])
consider that
this is not a proper copy-on-write list
because the clone immediately copies
instead of doing it when a write happens (append or set_item)
 
you'd need a reference to the original list, then instantiate that on the first (and only the first) operation, i think
 
5:36 AM
sure, but if you called clone right before the two functions, then then your list would be copy-on-write
 
@NathanMerrill you have a fundamental misunderstanding of copy-on-write
This is a proper copy-on-write list
class COWList:
    def __init__(self, l, clone_of=None):
        self.l = l
        self.clones = []
        self.clone_of = clone_of

    def append(self, val):
        self.clear_clones()
        self.l.append(val)

    def set_item(self, idx, val):
        self.clear_clones()
        self.l[idx] = val

    def get_item(self, idx):
        return self.l[idx]

    def clone(self):
        c = COWList(self.l, self)
        self.clones.append(c)
        return c

    def clear_clones(self):
        if self.clone_of is not None:
note that even if self.l is a gigabyte big list
you can call self.clone() thousands of times
as long as you do not modify those clones, they do not copy the list
if you modify the original the clones also copy
 
5:51 AM
wait...
so, lets say I have a, b, and c
they are all CowList clones
of a
if I modify a, it copies b and c?
 
correct
there is an opportunity to optimize it further
 
simply point c to b?
 
yeah something like that
but that requires more code
 
why not just copy a?
 
this was just to illustrate :)
@NathanMerrill because now b and c still think they're clones of a
ideally you just copy a
and then relink the clones such that one of the clones becomes the master, and the rest follows it
unless the number of clones is reduced to 1, which then just becomes normal
 
5:54 AM
but say you have 2000 clones
 
    def clear_clones(self):
        self.l = self.l[:]
        self.clone_of = None
        if self.clones:
            new_orig = self.clones.pop()
            new_orig.clone_of = None
            for clone in self.clones:
                clone.clone_of = new_orig
 
why not simply make a new copy, as opposed to updating the references of all of the clones?
actually, Wikipedia disagrees
"Instead they can all be given pointers to the same resource, with the provision that on the first occasion where they need to modify the data, they must first create a local copy on which to perform the modification (the original resource remains unchanged)"
 
@NathanMerrill in what way does it disagree?
 
well, in your case, you are modifying the original resource
and then reupdating the pointers
 
not anymore
see the new clear_clones
oh damn it's stupid now, it always copies
one sec
def clear_clones(self):
    if self.clone_of or self.clones: self.l = self.l[:]
    self.clone_of = None
    if self.clones:
        new_orig = self.clones.pop()
        new_orig.clone_of = None
        for clone in self.clones:
            clone.clone_of = new_orig
        self.clones = []
 

« first day (1939 days earlier)      last day (2903 days later) »