Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

How To Implement Closures?

Name: Anonymous 2014-06-11 16:44

As I understand, closures could be unboxed using a generated trampoline, like
mov rax, qword 12345678ABCDEFh ; 10 bytes function address
jmp rax ; 2 bytes
payload times N db 0 ; closure environment


Won't that mess code cache?

Name: Anonymous 2014-06-11 18:22

OSX disallows both WRITE and EXEC access. When you write C/C++ you're a professional, who know what he is doing, so such patronizing is an insult. Moreover, security is hyped and always gets in the ways, especially when compiler starts spitting warnings like gets() is obsolete. I know better what is obsolete, okay?

Name: Anonymous 2014-06-11 18:26

>>2
Moreover, security is hyped
Kill yourself.

Name: Anonymous 2014-06-11 18:27

>>3

No U.

Name: Anonymous 2014-06-11 18:32

>>2
The compiler warns according to the standard. A C11 compiler must warn the user about gets.

Name: Anonymous 2014-06-11 18:40

Also, NASM doesn't know about RIP register, so "lea rax,[rip]" fails, while Intel manual says that IP-relative addressing should work.

Name: Anonymous 2014-06-11 18:45

>>5
The best standard is C99 and it should be default. Forever.

But no. They ass-rape the standard every cumsucking decade just to troll and insult us.

Name: Anonymous 2014-06-11 21:21

leah cul,ver[rip]

Name: Anonymous 2014-06-11 23:42

You have been visited by the 9GET of Foolishness!

You have 9 minutes to repost this and 9GET. 99% of people will not 9GET and they will become baka...
              「o`':.‐ .._              _.. ‐::''´  ̄:`i
              |: : : :.::::::::`::‐.._       _.. ‐ ''´ : : : : : : : .::::::|
             |: : : : :__:: --―`――‐‐'::_ : : : : : : : : : : :...:::::::|
              _.':‐ '´            ` . : : : : : : :.::::::::::,!
 |、         /                   \ : : : : : :::::::/
 ヾ、._   ___,,.イ。                    \ : : : ::::〈
       ̄  /                    、     ヽ : ::::::::|
        ./           .!    i      .l .l     ',.::::::::::!
        /|   l   .l  | ,|    |       l l!     ',.::::::::|
      .//!  .| !  |  |/|    |ト、  | .!  |.|l |  l   ',:::::::|
        .'/ |   | |  |  ! |     .|! l|ヽ.|゙! |.  !!| l  |   .l、::::|゙:、
      l/ |  .l|| .! .__ハ、|. li    || | ゙| ゙!| |_ | | | .l   トヾj:::::゙:.、
       |!  .l  || lハ l「_ニト!、 l|、  ,!|_..l-‐ニ丁| | | | .!    |::::`\_ :\
       l   '.  || | ゙、〈´|。i゙! .l ゙.、| イi。il!:|.》|l   | l. |l    |! : : : : : : : ゙::...._
       |     '. || l   ヘ!弋ソ     ゙l 弋シ'/'|   .! l ,!|l    ゙、、::、- ..__: : : `::‐- .._ --
       l     ゙.|/   |///    __ ...... ////。 ,イ.' '   ||    ゙.、、\    ̄ ̄    /
          _.. ''//   ゝ、   「     .|/, ' / .l /   .!l、_   ヘ\ `         ./
   _. - '' _./イ    ,i/|`! ‐ ._`ー  '_//   //_....._ ヘ.  \.  | '.         /
   '.    ̄  /。  _,.イl ゙ | ゙! _..`T ´〈 〈   ̄/'    ` 、゙.、  ゛. |  l  ___,,. -‐'
    '.      | /´  ゙|\゙y '´/イ_.. '´\、.i'/ _ ___   .|._\-‐'.|''´ ̄
     '.    ゙、|    / /^ゝ「ヽ.   ,.×!´ -`i _l_>'i'┤_ _ _ _ ___
     ゙.      l   ,. ' ,.l「_プi「`》. ヽ/ :::::|     j´ `⌒´゙ヽ           `'' .._
       ゙、 _ ___./  / .:´.:l∠゙V'-''´:::::::::::::l`ー‐"|  |  :l  ゙!             `'' .._
          __| ./ : :..:.: : : : : : :::::__...-‐ノ...:‐┬ト  .j   |   l                `'' .._
    ,. ' ̄  ̄ ./ .7 : : : : : : : : :( ̄   __.:.:.__:.l ゙ ./__... '-‐'"               _ -‐ "´
  , '        ヽ,_,i : : : : : : : : : : :`'ー ''´:::: ̄::/ `¨´ `'' .._           _. -‐ ''"´
.            .| .|: :::::::::::::::::::::::::::::::::::::::::::::::..:/`'' - ._    `'' .._ _. -‐ ''"´
.._           / |: :::::::::::::::::::::::::::::::::::::::::::.: :/     `'' - ._   `

Name: Anonymous 2014-06-12 1:56

>>2
but you can have write access at the start and after that remove it and give it exec access, right?

>>7
C99 sucks[1], every C standard[2], even C11[3] sucks but C still the best language

[1]: C++ style commends, inline functions, intermingled declarations and code, long long int, _Bool instead of bool, universal character names, tgmath.h without giving a standard way to implement it (fixed in C11 with the badly designed _Generic)
[2]: non-thread safe functions (ex strtok), unsafe functions (ex gets, sprintf, scanf), lack of good high level functions for dynamic memory handling (eg getline from POSIX [still shit but anyway], strdup, asprintf, etc...), everything in time.h, useless functions like printf (we have already fprintf) and getc/putc (we have fputc/fgetc), no atleast N-bit integer (except from [u]int_{least/fast}{8,16,32,64}_t), useless auto keyword
[3]: nigger_s, makes variable length arrays optional even in hosted implemetations, _Generic is badly designed, _Alignas, _Alignof instead of alignas, alignof, _Noreturn instead of noreturn, _Thread_local instead of thread_local, _Atomic instead of atomic, _Static_assert instead of static_Assert (it is also badly designed)

Name: Anonymous 2014-06-12 2:09

>>10
No, I'm pretty sure LISP is the best language(family).

Name: >>10 2014-06-12 2:10

[2]: no overflow checking functions, other kind of unsafe functions (like atoi, shit like strftime), lack of ssize_t (that can hold everything size_t can + atleast 1 bit), lack of [s]size_t function that can hold the maximum value of size_t * CHAR_BIT, intptr_t/uintptr_t are optional and badly designed, lack of [u]intptr_t type that can hold the maximum value of intptr_t * CHAR_BIT, lack of a byte type that is atleast 1 bit instead of char (char is atleast 8 bit and can be more even if you have 8-bit bytes if the encoding is more than 8 bit)

Name: Anonymous 2014-06-12 2:15

>>11
I hate (begin) and many of the shit it has but yes scheme is very cool, I am not sure about Common lisp because I never used it nor read about it

Name: Anonymous 2014-06-12 2:29

>>10
but you can have write access at the start and after that remove it and give it exec access, right?
That is a lot of non-portable work. Moreover, mprotect isn't guaranteed to succeed on non-mmaped pages. I.e. if you prefer bss allocation, mprotect may fail.

Name: Anonymous 2014-06-12 2:48

_Alignas, _Alignof instead of alignas, alignof, _Noreturn instead of noreturn, _Thread_local instead of thread_local, _Atomic instead of atomic

I don't see the problem. Because none of your proposed alternatives were keywords previously the standard uses the ugly _Reserved form; if you don't have name clashes in existing code you just can include the appropriate header (which the standard also provides for) and use lower case via preprocessor macros.

_Static_assert instead of static_Assert (it is also badly designed)

It's not badly designed; it's crippled by the semantics that the rest of the language had already defined.

Name: Anonymous 2014-06-12 2:58

>>12
[2]: no overflow checking functions

Because not every architecture has a flags register.

other kind of unsafe functions (like atoi, shit like strftime)

All shit yes; but too old and widely used to remove at this point.

lack of ssize_t (that can hold everything size_t can + atleast 1 bit)

Not possible unless you're comfortable with having sizeof(size_t) != sizeof(ssize_t).

lack of [s]size_t function that can hold the maximum value of size_t * CHAR_BIT

And this is useful because you address bits when?

intptr_t/uintptr_t are optional and

Because not all architectures interpret integers as pointers into a flat address space.

lack of a byte type that is atleast 1 bit instead of char (char is atleast 8 bit and can be more even if you have 8-bit bytes if the encoding is more than 8 bit)

That's what int is for.

Name: Anonymous 2014-06-12 3:24

>>16

Because not all architectures interpret integers as pointers into a flat address space.
x86 uses two integers to define a pointer, but you can still define default segment to emulate singe-integer pointers.

Name: Anonymous 2014-06-12 3:32

>>15
if you don't have name clashes in existing code you just can include the appropriate header
I though that it is undefined behavior if you redefine things that are used in headers even if you do not include them but I can not find where the standard says that so ignore this point

>>16
Because not every architecture has a flags register.
This is not what I mean at all, I am thinking of a function like checkOverflow_mul (int, int)

All shit yes; but too old and widely used to remove at this point.
I am not proposing to remove them, I am just saying that the older standards suck because of introducing them and new standards suck because of not introducing new ones that fix these problems

Not possible unless you're comfortable with having sizeof(size_t) != sizeof(ssize_t).
I can not see a problem with this, most people are using ssize_t as a size_t with the ability to ``throw'' an error (if 0 is a valid value) or in other cases like this

And this is useful because you address bits when?
many times for example if you want to create a array of char, int or anything that you access it per bit
bitArray *createBitArray (bit_size_t numberOfElements);
bool getbit (const bitArray *bitarray, bit_size_t N);
void setbit (bitArray *bitarray, bit_size_t N, bool something);


Because not all architectures interpret integers as pointers into a flat address space.
I did not have them in my mind for usage of them as pointers but for being able to do things like counting the items of a linked list, a type that can hold all the possible addresses would be the only one that for sure would be able to fit the maximum number

That's what int is for.
int is not a byte last time I checked and it is atleast 16 bits

Name: Anonymous 2014-06-12 3:59

Why not just create and use your own version of c like Terry did with HolyC?

Name: Anonymous 2014-06-12 4:10

>>19

What is the license of HolyC?

Name: Anonymous 2014-06-12 4:13

>>19
99% of the problems are in the standard library but that does not seem like a bad idea

Name: Anonymous 2014-06-12 4:22

many times for example if you want to create a array of char, int or anything that you access it per bit

And the arrays you are accessing can be up to 1 / CHAR_BIT of your address space? Just typedef unsigned long bit_size_t and be done with it.

I did not have them in my mind for usage of them as pointers but for being able to do things like counting the items of a linked list, a type that can hold all the possible addresses would be the only one that for sure would be able to fit the maximum number

That's exactly what size_t is supposed to be for.

Name: Anonymous 2014-06-12 4:28

>>22
Just typedef unsigned long bit_size_t and be done with it.
This is very limited

That's exactly what size_t is supposed to be for.
this is not the case at all, size_t is guaranteed to be big enough to contain the size of the biggest object your system can handle. a linked list has many nodes, it is not one object in C

Name: Anonymous 2014-06-12 5:36

>>19
Good luck trying to get these idiots to do anything challenging (they aren't even capable of it). Look at how they can't even figure out what the actual issue is. Fuckin imbeciles. Look, these jokers know nothing more than introductory computer science (SICP) and have a tough time functioning even at the most basic levels in life. They have more of a chance of losing their precious virginity (prostitutes) than programming something that will get their name on wikipedia.

Name: Anonymous 2014-06-12 5:42

>>24
EPIC xDD lelelele

Name: Anonymous 2014-06-12 6:05

>>16
Not possible unless you're comfortable with having sizeof(size_t) != sizeof(ssize_t).
How is this a problem? What if you want the (signed) difference between two size_t values?
size_t a = (size_t)-1;
size_t b = 0;
ssize_t c = a - b;

Name: Anonymous 2014-06-12 8:15

>>24
Kill yourself you fucking retarded theist cunt.

Don't change these.
Name: Email:
Entire Thread Thread List