Re: [dev] Suckless remote shell?

From: Alexander S. <alex0player_AT_gmail.com>
Date: Fri, 8 Nov 2013 08:22:37 +0400

2013/11/8 Szabolcs Nagy <nsz_AT_port70.net>:
> * Alexander S. <alex0player_AT_gmail.com> [2013-11-08 02:10:49 +0400]:
>> 2013/11/7 Szabolcs Nagy <nsz_AT_port70.net>:
>> > with a single pointer arg this assumes that all pointers have
>> > the same representation or that you create a separate version
>> > of pthread_create for every type used
>> Pthread_create doesn't need to know anything about the type of the
>> pointer! In fact, nobody except the typechecker needs to.
>
> if different pointers have different representations
> then the caller needs to know that at runtime to pass
> the argument to the callback
>
>> Runtime information is only needed if you are going to actually
>> introspect that arbitrary number of args. If you are going to plop
>> them back onto the stack, the only thing you need to know is a total
>> size, which can be calculated in compile time.
>
> that's not how the function call abi works
>
> and what you describe can be done now in c without the syntax:
> allocate a char array on the stack serialize everything into it,
> and pass the pointer and size
>
> you don't get typesafety, but that cannot be done in general
> accross a serialize/deserialize step, you could only type
> check a few special case of that at best.. by making things
> more complicated

There seems to be some misunderstanding about what is type-safety and
when checks are made.
They are actually made when you are calling a function with signature
described above. I used higher-order lambda to express the notion
that, for example, an extra argument in pthread_create is the same
type as the only argument to its entry point. To the *implementation*,
these are just opaque pointers. We don't get our typechecking by
substituting templates and checking that calls don't violate the
rules; something more beautiful is going on here. (C++ templates don't
support type lambdas, sadly).

>> expansion C varargs undergo. But, I suppose, asking that all arguments
>> be either floating-point or pointer-size isn't asking too much. It is
>> doable.
>
> the size is not all
>
> there are function pointers, structures with alignment requirements,
> paddings and bitfields, some implementations support more than three
> different floating-point types..
>
> in the end you either have runtime type information to be able to
> unpack the arguments and construct calls with them or you have what
> c has now

Structures are usually passed by pointer anyway if they don't fit in
64-bit register, I believe?
Of course, you can do serialization by hand; but that way, you get it
exactly right in one line looking almost like a call. And a free
type-checking! (See above about why it's compile-type and why
implementation doesn't need to care about it).
But yeah, there is probably not much point in such varargs without
runtime information. They cannot even be used for printf or alike.
Received on Fri Nov 08 2013 - 05:22:37 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 08 2013 - 05:24:07 CET