« first day (2358 days earlier)      last day (2490 days later) » 

5:00 PM
If you do int* loc=b; it works fine
 
@Cowsquack that's above my paygrade
@BusinessCat why doesn't it work if I do int loc = b; int *c = loc;?
 
I'm trying to print what's in the second byte of the int but am failing
if it's even possible
 
Solution: Make everything a void*
How does pointer arithmetic work on void*? What does it consider the size of a void?
 
Solution: Don't use C
 
what is a void *? Is it just typeless?
 
5:03 PM
@LeakyNun because loc is an int, not an address. You want &loc
@Cowsquack yes
 
@Phoenix 1 byte
 
@DJMcMayhem what if I want to treat it as an address?
 
@Cowsquack It's like Object in C#/Java. You can store whatever you want in there.
 
okay
 
@LeakyNun (I haven't tested this) You might be able to do int *c = (int*)loc, but that's a terrible terrible idea.
If that doesn't work, you should look into memset
 
5:04 PM
it still segfaults
 
Or unions which is easier
@LeakyNun Yeah, I'd expect that
 
@DJMcMayhem no I don't want to set the memory
 
Wait, so what exactly do you want to do? You have an int, and you want to use that value of the int as the address of a new pointer?
 
@DJMcMayhem yes
 
Is this for something legitimate? Because I don't know what you're doing but I'm positive there's a better way
 
5:05 PM
That's a segfault waiting to happen
2
 
@Phoenix although technically, C# does have void*s...
 
Either way, that's not really going to work since an int* is one byte and an int is (usually) 4 bytes.
 
@DJMcMayhem no way
when I print an int* it gives me 864298784
 
The size of an int isn't specified, short is guaranteed to be 2 bytes and long is guaranteed to be 4 bytes. iirc.
 
that's a long byte
 
5:07 PM
Wait, ignore me
Sorry, I don't know why I said an int* is one byte
That's obviously false
 
On a 32 bit system, an int* is 4 bytes, on a 64 bit system, it's 8 bytes.
 
so int* is a pointer that points to an int?
 
Yes.
 
@Cowsquack yes
 
Also known as an int array.
 
5:08 PM
(insert mandatory pointer-is-not-array reference)
 
int b = loc;
int *c;
memcpy(c, &b, 4);
 
so it points to a location
 
Let the records show that I'm against this horrible code
 
Yep
 
Although, 4 is not really correct, cause it depends on architecture
 
5:09 PM
@DJMcMayhem so sizeof(int*)?
 
Yes
@LeakyNun Alternate approach:
 
that means TIO is on a 64 bit system
 
    union Abomination {
        int loc;
        int *pLoc;
    }

    Abomination dont_do_this;
    dont_do_this.loc = loc;
    int *c = dont_do_this.pLoc;
 
@Cowsquack Yes
 
How do you like my var names? :P
 
5:11 PM
You can tell because Assembly (as, x64, Linux)
 
@DJMcMayhem still segfaults
 
6 mins ago, by Business Cat
That's a segfault waiting to happen
That's because you probably aren't allowed to touch wherever the value of loc happens to randomly point at
Also, what is int c = b;?
 
@LeakyNun d (usually won't) point to a valid address.
 
@Riley but logically it would
 
Why?
 
5:14 PM
@LeakyNun It isn't initialized. In this case, it's probably 0.
 
@DJMcMayhem just look into my code
@Riley I actually initialized it
 
@LeakyNun Where?
 
@Riley b[0]=2?
 
@LeakyNun That has nothing to do with d.
 
@Riley but d is c which is b
 
5:16 PM
@LeakyNun I have. I don't quite get it. What is int c = b supposed to do?
c != b because b is a pointer, and c is an int
 
I cast it
 
No you didn't
 
You are copying into the address that d points to, but you never set the address that d points to.
 
@LeakyNun Ooooooh, you want memcpy(&d,&c,sizeof(int*));
That's right
 
@Cowsquack Shocking.
 
5:18 PM
memcpy(d,&c,sizeof(int*)); is copying into the location of d (unassigned), not the pointer itself
@Riley (thanks)
 
@Riley no, I want d to be equal to b
 
Try it online! seems to do what you want (notice that the last line still segfaults though)
 
@LeakyNun Oh, then do what DJMcMayhem said.
 
@Riley then it segfaults
 
5:21 PM
Of course it does
Dennis Ritchie would be turning over in his grave.
 
I guess I'm still not quite sure what you're trying to do.
 
Can someone have a look at this? I'm thinking of posting and want a last minute check
 
._.
 
ಠ_ಠ
 
5:35 PM
 
@BusinessCat at least that one has html
lulz
 
CMC: 1^2 + 2^2 + ... + n^2
 
Given N?
 
sure
 
:U in MATL
And in jelly I think?
 
5:42 PM
@DJMcMayhem what sorcery is this
@DJMcMayhem no it wouldn't work
 
Oh sorry, I misunderstood
@LeakyNun :Us
 
R²S is Jelly
 
english: range, vector square, sum
 
@LeakyNun 05AB1E, 3 bytes: LnO
 
try to do it... in languages where this wouldn't be trivial
 
5:43 PM
That would be a great challenge for brain-flak
 
@DJMcMayhem no it wouldn't
 
I'll do that in a few minutes
@LeakyNun Totally would
 
it's just a cubic polynomial
 
well if i manage to implement range and map in ,,,: R[2*]#
 
do it in oasis
 
5:45 PM
lambda n:sum(i**2for i in range(1,n))
 
@totallyhuman you can get smaller
 
@totallyhuman In Gaia I made range and map but I haven't made a n^2 operator yet so I guess I have the opposite problem ¯\_(ツ)_/¯
 
if it involves crazy math i have no idea :P
 
@BusinessCat just multiply n by itself
2 mins ago, by Leaky Nun
it's just a cubic polynomial
 
I also don't have a sum operator yet so I'd have to reduce by addition
 
5:49 PM
@BusinessCat what is Σ?
oh, notImplemented
 
It going to be sum, I just haven't made it
I could do it in 5 bytes for now: :׆+⊢
 
@LeakyNun Brain-Flak, 36 bytes: ({<(({}[()])())>{({})({}[()])}{}}{})
 
@Riley nice
 
Sum could be unary addition on lists.
 
5:50 PM
36 is a lot shorter than I expected it to be
 
I bet it could be shorter still
 
4 mins ago, by Leaky Nun
2 mins ago, by Leaky Nun
it's just a cubic polynomial
 
@BusinessCat When I actually make these operators it'd just be s¦Σ
 
CMC (language-specific): write some code so that + would be evaluated as *
 
#define + * i think
 
5:53 PM
language specific because it might not be possible in some languages
 
Evaluated as * normally is in that language?
 
i don't know c though
 
@BusinessCat I mean, addition as multiplication
 
At least one language out there, +=*. plsplspls
 
@totallyhuman is that right? anybody who can c?
 
5:54 PM
o/
 
int operator +(this int a,int b)=>a*b works in C# I think maybe?
 
It's right
 
Oh yeah, in Scheme you can do (define + *)
 
@DJMcMayhem but it would produce side effect like +a being treated as a pointer?
 
Yes
 
5:55 PM
lol
 
It would scan through the whole file before compiling, look for any occurences of +, and replace it with * before getting to the compilation stage.
 
in python you'd probably just redefine int.__add__ and other classes
int.__add__ = int.__mul__
 
@Phoenix No, you can't define extension methods for operators
 
aw it doesn't allow it
 
TypeError: can't set attributes of built-in/extension type 'int'
 
5:57 PM
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> int.__add__ = int.__mul__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't set attributes of built-in/extension type 'int'
>>>
 
you both were ninja'd
 
I know
 
imaginary cookie for anyone who does it via java reflection
 
Jim
@LeakyNun Pyth: D+GHR*GH
 
@LeakyNun I think Java doesn't allow that, but I'm not sure.
 
5:58 PM
@Jim hmm, nice
 
@LeakyNun I do not believe that to be possible without modifying the source and javacing it.
 
@HyperNeutrino I thought everything is possible in java reflection
 
Well not redefining variables
 
You can't do normal operator overloading with Java reflection.
 
because addition in Python does a + b => a.__add__(b)
but a + b in Java is just a + b
 
5:59 PM
but you can change 4 into 5, lol
 

« first day (2358 days earlier)      last day (2490 days later) »