Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

hackbunny posted:

a generic argument that's a (numeric) value instead of a type. like say, you have a dynamic list of poops and it's list<poop>, but a statically sized array of poops is array<poop, 420>: first generic argument is a type (the type of array elements), the second is an integral argument (the number of array elements)


Powaqoatse posted:

i think its like Array<3> so you know it only has 3 elements or Matrix<3,5> etc

and the compiler can error-check/optimize based on that

e: fb, woot i guessed it right

:tipshat:

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



i cant really find any articles online though, are they also called something else?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
sounds like a special case of dependent types to me.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



oh yeah that makes sense

JawnV6
Jul 4, 2004

So hot ...
oh a size_t

tef
May 30, 2004

-> some l-system crap ->
if it involves counting and type systems you're going to have an awful time

All Too Much For Me
Aug 14, 2008

tef posted:

if it involves counting and type systems you're going to have an awful time

I have 22 arguments about this

JewKiller 3000
Nov 28, 2006

by Lowtax

All Too Much For Me posted:

I have 22 arguments about this

you'll need to provide a constructive proof of those 22 arguments or i'm not even going to compile them much less listen to them :colbert:

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

All Too Much For Me posted:

I have 22 arguments about this

TOPS-420
Feb 13, 2012

is that 20+2 or 2+20 arguments? please construct a witness proving these are equivalent

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

TOPS-420 posted:

is that 20+2 or 2+20 arguments? please construct a witness proving these are equivalent

wish I could construct a witness to your posts

(who is not me)

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

MALE SHOEGAZE posted:

sounds like a special case of dependent types to me.
people say this a lot and it bugs me, because the coolest part of real dependent types is that you don't need to know the actual value your type depends on at compiletime. in C syntax, you can do stuff like struct { size_t n; int foo[n]; }

Ralith fucked around with this message at 02:58 on Aug 31, 2017

Sapozhnik
Jan 2, 2005

Nap Ghost

TOPS-420 posted:

is that 20+2 or 2+20 arguments? please construct a witness proving these are equivalent

how the gently caress do you prove a group axiom exactly

tef
May 30, 2004

-> some l-system crap ->
very carefully

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
lol if your type system can't express commutativity of addition in Z^n

sarehu
Apr 20, 2007

(call/cc call/cc)

Sapozhnik posted:

how the gently caress do you prove a group axiom exactly

It depends on how you define the particular group.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Ralith posted:

people say this a lot and it bugs me, because the coolest part of real dependent types is that you don't need to know the actual value your type depends on at compiletime. in C syntax, you can do stuff like struct { size_t n; int foo[n]; }

obviously there would be many things swift would not allow, but we could actually handle some amount of dynamicism here

Doom Mathematic
Sep 2, 2008

hackbunny posted:

a generic argument that's a (numeric) value instead of a type. like say, you have a dynamic list of poops and it's list<poop>, but a statically sized array of poops is array<poop, 420>: first generic argument is a type (the type of array elements), the second is an integral argument (the number of array elements)

Didn't Pascal have this? And it was turned on by default, as in every array was sized and the size was part of the array type? And it was one of the worst features of Pascal?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
pascal had fixed-size arrays and iirc no portable way to generalize over them. allowing code to be generic over an integer does give you a way to generalize over them (as would e.g. allowing them to decay to a pointer/length pair, or even just a pointer as c does)

TOPS-420
Feb 13, 2012

ansi pascal had no polymorphism over array sizes and no dynamically sized array or string types, so you could only write a function for a specific array size

e: fb

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Pascal was the second language i learned after quickbasic

i remember basically nothing about it other than how frustrated i was at array sizes

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

rjmccall posted:

pascal had fixed-size arrays and iirc no portable way to generalize over them. allowing code to be generic over an integer does give you a way to generalize over them (as would e.g. allowing them to decay to a pointer/length pair, or even just a pointer as c does)

so to get around this you would what? declare a larger array and fill up what you weren't using with null and write boilerplate to strip it out?

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
Relevant http://doc.cat-v.org/bell_labs/why_pascal/why_pascal_is_not_my_favorite_language.pdf

Fergus Mac Roich
Nov 5, 2008

Soiled Meat
https://doc.rust-lang.org/std/primitive.array.html

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ultravoices posted:

so to get around this you would what? declare a larger array and fill up what you weren't using with null and write boilerplate to strip it out?

if you need a dynamically-sized array then yeah, you can just treat the length as a max capacity and store a size along with it. the basic set-up is not that different from c except that c actually gives you the ability to form pointers

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
but pascal does have pointers? hell, it's how I learned pointers. or was it a borland extension

akadajet
Sep 14, 2003


today this would be "pascal_is_a_piece_of_shit_for_morons.pdf"

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

akadajet posted:

today this would be "pascal_is_a_piece_of_shit_for_morons.pdf"

He's canadian. "not my favorite" is canadianese for "poo poo from a butt"

akadajet
Sep 14, 2003

is pascal the original p-lang?

TOPS-420
Feb 13, 2012

ansi pascal had pointers, but you could only alloc/delete single values iirc. you could build a linked list or tree but you couldn't do pointer arithmetic

turbo pascal fixed basically all the problems with pascal by making string a proper type and adding c-style pointer arithmetic

e: also by having the greatest compiler box art of all time

TOPS-420 fucked around with this message at 18:10 on Aug 31, 2017

tef
May 30, 2004

-> some l-system crap ->

akadajet posted:

is pascal the original p-lang?

MORE LIKE P-LANG

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

hackbunny posted:

but pascal does have pointers? hell, it's how I learned pointers. or was it a borland extension

it has pointers, but there’s no standard ability to take the address of things, or to do pointer arithmetic, so you can’t use pointers as a generalization mechanism the way you can in c

raminasi
Jan 25, 2005

a last drink with no ice

kind of interesting to see someone talk about how cool and good (function-level) static is and how lame pascal is for not having it

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

raminasi posted:

kind of interesting to see someone talk about how cool and good (function-level) static is and how lame pascal is for not having it

i'm a dumb baby, that is 1980-ese for a global variable, right?

tef
May 30, 2004

-> some l-system crap ->

raminasi posted:

kind of interesting to see someone talk about how cool and good (function-level) static is and how lame pascal is for not having it

welcome to the golang party

CPColin
Sep 9, 2003

Big ol' smile.

ultravoices posted:

i'm a dumb baby, that is 1980-ese for a global variable, right?

The PDF posted:

A static variable (often called an own variable in Algol-speaking countries) is one that is private to some routine and retains its value from one call of the routine to the next.

So it's scoped to the function, but keeps its value between calls.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
right. it's not like pascal is taking a principled stand against global variables, it's just forcing them to be declared as true globals instead of allowing them to be function-scoped. also note that pascal requires global variables to be declared in a single block at the top of the source file so that might be really far away from the function definition

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

I've heard many people speak praise of modern FreePascal and the Lazarus ide in particular, never actually checked it out myself but I'm kinda curious. Supposedly it's quite good at cross platform GUI development

ultravoices
May 10, 2004

You are about to embark on a great journey. Are you ready, my friend?

CPColin posted:

So it's scoped to the function, but keeps its value between calls.

okay you sort of can do that in python by with hasattr, it will retain state between function calls but the attribute will be accessible from outside the scope of the function.

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

TOPS-420 posted:

ansi pascal had no polymorphism over array sizes and no dynamically sized array or string types, so you could only write a function for a specific array size

e: fb

talk about a swing and a miss

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply