Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 21:39

    gafter on master

    Propose Feb 11 agenda (#2187) (compare)

  • Jan 31 2019 21:39
    gafter closed #2187
  • Jan 31 2019 19:42
    gafter edited #2115
  • Jan 31 2019 15:46
    jcouv edited #1565
  • Jan 31 2019 14:51
    yigitgursoy closed #1958
  • Jan 31 2019 13:43
    ichensky closed #2190
  • Jan 31 2019 12:17
    ichensky opened #2190
  • Jan 31 2019 04:38
    MarkPflug edited #2189
  • Jan 31 2019 04:37
    MarkPflug edited #2189
  • Jan 31 2019 04:37
    MarkPflug edited #2189
  • Jan 31 2019 04:36
    MarkPflug opened #2189
  • Jan 30 2019 23:15
    MohammadHamdyGhanem opened #2188
  • Jan 30 2019 20:01
    gafter review_requested #2187
  • Jan 30 2019 20:01
    gafter review_requested #2187
  • Jan 30 2019 20:01
    gafter review_requested #2187
  • Jan 30 2019 20:01
    gafter assigned #2187
  • Jan 30 2019 20:01
    gafter opened #2187
  • Jan 30 2019 20:00

    gafter on gafter-2019-02-11-agenda

    Propose Feb 11 agenda (compare)

  • Jan 30 2019 17:11
    tannergooding opened #2186
  • Jan 30 2019 15:52
    lust666 closed #2185
CyrusNajmabadi
@CyrusNajmabadi
verify they divide equally based on the number of elements
Michał Zegan
@webczat
ah yes, if the method would be generic... then you would need something like that, right? doesn't sizeof operator work too?
CyrusNajmabadi
@CyrusNajmabadi
submit pr?
Yair Halberstadt
@YairHalberstadt
But it does some pointer reinterpreting for performance
Well thats what I'm working on :-)
CyrusNajmabadi
@CyrusNajmabadi
ah :)
ah yes, if the method would be generic... then you would need something like that, right? doesn't sizeof operator work too?
you can't use sizeof on a type-parameter
Michał Zegan
@webczat
eeee... okay didn't know
CyrusNajmabadi
@CyrusNajmabadi
although, if you added the unmanaged constraint, it shoudl work
nto sure if we ever updated it accordingly
Michał Zegan
@webczat
well I assumed I would have a generic type with the constraint, for this case it's reasonable isn't it?
Yair Halberstadt
@YairHalberstadt
Michał Zegan
@webczat
but... well would have to verify
CyrusNajmabadi
@CyrusNajmabadi
the unmanaged constraint is very new
and it would technically be a breaking change to add it
so it depends on when the API shipped, and what breaks they'll allow
docs just say this: public static Span<TTo> Cast<TFrom,TTo> (Span<TFrom> span) where TFrom : struct where TTo : struct;
not: public static Span<TTo> Cast<TFrom,TTo> (Span<TFrom> span) where TFrom : unmanaged where TTo : unmanaged;
i'm going to presume the docs are accurate. but i have no idea
Michał Zegan
@webczat
but it doesn't check lengths and throw. so the wrapper method could use unmanaged constraint as it doesn't exist now :)
Yair Halberstadt
@YairHalberstadt
CyrusNajmabadi
@CyrusNajmabadi
so the wrapper method could use unmanaged constraint as it doesn't exist now :)
yes, do whatever you want there
i was talking about what Cast/Sizeof could do :)
Michał Zegan
@webczat
also the method description says about casting between spans of primitives. except bool all of them are unmanaged right?
CyrusNajmabadi
@CyrusNajmabadi
it would only ever allow unmanaged types
Michał Zegan
@webczat
as for what docs show, I believe there are some things docs don't show. for example last I checked they didn't show ref returns as ref returns, and they likely didn't show nullable annotations :)
CyrusNajmabadi
@CyrusNajmabadi
Neither TFrom nor TTo can contain pointers or references. TFrom and TTo are checked at runtime in order to preserve type safety.
so it's hwo the runtime did unmanaged before c# added that
Michał Zegan
@webczat
yeah.
CyrusNajmabadi
@CyrusNajmabadi
they likely have some helper. intrinsic or otherwise
don't know, don't care :)
Michał Zegan
@webczat
:)
I am just thinking what breaks could adding unmanaged constraint cause. although it doesn't mean it has to be added because it's runtime checked anyway. Was just curious, don't care more
Joseph Musser
@jnm2

@webczat

yeah. I know it has GetPinnableReference

GetPinnableReference returns a stack-only value

CyrusNajmabadi
@CyrusNajmabadi
I am just thinking what breaks could adding unmanaged constraint cause.
anyone who passes a managed struct type wuld now break at compile time
instead of runtime
Joseph Musser
@jnm2
@webczat The point of using Memory instead of Span is for when you have to put things on the heap
CyrusNajmabadi
@CyrusNajmabadi
there might be code that actually is ok with that, and has a try/catch around the call
Michał Zegan
@webczat
well
CyrusNajmabadi
@CyrusNajmabadi
you've now broken that code
Joseph Musser
@jnm2
@webczat If the pinning needs to live longer than your stack lasts, you call Pin
CyrusNajmabadi
@CyrusNajmabadi
because it won't compile anymore
Joseph Musser
@jnm2
@webczat If it doesn't, you do fixed with memory.Span
Michał Zegan
@webczat
when pinning needs to be long lived? some possibly long lived native code in the background that may mess with this thing?
Joseph Musser
@jnm2
yes