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
a cyberpunk goose
May 21, 2007

I like the Haxe designer's approach to access control (not specific to const but moreso to class privacy):

quote:

You can access the private fields of a class or package by using @:access metadata. In fact, you can even use multiple @:access declarations in exactly the same way as @:allow.

You might say that this goes against the wishes of the original author of the library's source code. And typically, you would be right. If the field is private, it may be implementation-specific behavior that could change between library versions. So, for the most part, don't muck around with other people's privates.

There comes that one time in a hundred, however, where you need to mess around with internal details. That's why we're letting you touch people's privates if you deem it necessary, possibly for things like profiling or debugging. The Haxe philosophy is that the developer knows what he or she is doing, and that any weird features like forcing public member access must be used explicitly.

:tipshat: glad to contribute nothing to the conversation

funny-internet-snipe.gif

Adbot
ADBOT LOVES YOU

Nomnom Cookie
Aug 30, 2009



I have zero faith that const helps the compiler catch actual mistakes. The C++ obsession with const correctness smells like Asperger's to me. Const is also a crutch that C++ programmers use to avoid thinking about mutation at design time, because anyone who wants immutability can just use const!

Pollyanna
Mar 5, 2005

Milk's on them.


why is programming a gui in python such a pain in the rear end

JewKiller 3000
Nov 28, 2006

by Lowtax

FamDav posted:

passing a reference by value is equivalent to passing a value by reference

NO IT ISN'T, this was the central point of my previous posts. please read them again if you still believe this

Pollyanna
Mar 5, 2005

Milk's on them.


Pollyanna posted:

programming a gui in python

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Pollyanna posted:

why is programming a gui in python such a pain in the rear end

just break down and use html as a poor man's gui toolkit

Nomnom Cookie
Aug 30, 2009



Mido posted:

I like the Haxe designer's approach to access control (not specific to const but moreso to class privacy):


:tipshat: glad to contribute nothing to the conversation

funny-internet-snipe.gif

Java has this also in the reflection API. It's even somewhat endorsed by the JCP--some JSRs specify that the library will reach into your objects and mess with private members. The reason it doesn't cause a problem, I think, is that the class indicates to the framework what the framework should do to the class's privates. It's when you start touching privates without an invitation that you have an issue.

a cyberpunk goose
May 21, 2007

Nomnom Cookie posted:

Java has this also in the reflection API. It's even somewhat endorsed by the JCP--some JSRs specify that the library will reach into your objects and mess with private members. The reason it doesn't cause a problem, I think, is that the class indicates to the framework what the framework should do to the class's privates. It's when you start touching privates without an invitation that you have an issue.

just like real life

Nomnom Cookie
Aug 30, 2009



Someone tell the Ruby programmers to stop touching privates without permission, their bad behavior is really getting out of hand.

Pollyanna
Mar 5, 2005

Milk's on them.


Malcolm XML posted:

just break down and use html as a poor man's gui toolkit

i am seriously tempted to now. tkinter is better than this poo poo. at least it has documentation

Nomnom Cookie
Aug 30, 2009



Buy a Mac and use Cocoa, the only decent GUI toolkit.

Bloody
Mar 3, 2013

Nomnom Cookie posted:

Buy a pc and use wpf, the only decent GUI toolkit.

shaggaring is easy

Pollyanna
Mar 5, 2005

Milk's on them.


Nomnom Cookie posted:

Buy a Mac and use Cocoa, the only decent GUI toolkit.

i do in fact have a mac!

and im considering just moving to objc (even if the syntax is balls)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Pollyanna posted:

i do in fact have a mac!

and im considering just moving to objc (the syntax is a ball)

a cyberpunk goose
May 21, 2007

Pollyanna posted:

i do in fact have a mac!

and im considering just moving to objc (even if the syntax is balls)

i dont know what you're up to but obj-c isn't bad and neither is like C#/xamarin stuff but you gotta pay to use the macos native widgets but you can use... gtk... actually don't go down this path

just don't


forget i ever said anything

run from this place

JewKiller 3000
Nov 28, 2006

by Lowtax

JewKiller 3000 posted:

NO IT ISN'T, this was the central point of my previous posts. please read them again if you still believe this

in case another repetition helps:

when you pass a reference by value, you have two copies of the reference, one on the caller's stack, and another on the callee's stack
when you pass a value by reference, you have just one copy of the value, on the caller's stack. uses of the corresponding argument by the callee refer back to this single value on the caller's stack, and no copy is made. hence the name "pass by reference"

if this doesn't matter for your use cases so you don't care, that's fine
but you shouldn't go claiming that the two things are equivalent when the distinction between them can be very important
especially since, as we have seen in this thread, there are a lot of people with incorrect understanding of evaluation strategies

Brain Candy
May 18, 2006

JewKiller 3000 posted:

1) yes but only in rare cases, and before you use it, think hard about whether you really need to
2) absolutely not

and this is the absolute opposite of every language i can get paid to code in :smith:

JewKiller 3000
Nov 28, 2006

by Lowtax
somehow they're still paying me to write my code in ocaml, a language that meets those criteria :)

oh right i know how, it's because nobody else at the company can even read my codebase much less modify it, and it does things that the business needs done. worksforme wontfix

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

JewKiller 3000 posted:

NO IT ISN'T, this was the central point of my previous posts. please read them again if you still believe this

eh, no, he's actually sort of right here. it's still not "pass-by-reference", but passing a pointer still means that you can mutate stuff "in" the previous function's scope. which can get messy in very obvious ways.

Pollyanna
Mar 5, 2005

Milk's on them.


Mido posted:

but you gotta pay to use the macos native widgets

what

Pollyanna fucked around with this message at 03:03 on Sep 27, 2013

Max Facetime
Apr 18, 2009

Pollyanna posted:

i do in fact have a mac!

and im considering just moving to objc (even if the syntax is balls)

oooh, you are planning on tying yourself to a single-vendor ecosystem and reliving the cool 90's?

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


Nomnom Cookie posted:

You're conflating reference mutation with value mutation. If the object is supposed to be immutable, then it will be written that way. If it's supposed to be mutable, then why the hell are you trying to make it immutable? Const StringBuilder is a ridiculous notion.

i do know the difference between the two, i just think final should make not only the reference immutable, but the members of the object it refers to.

as for why, sometimes it's nice to have some guarantees that this function, or this piece of code, or whatever, can't gently caress around with the state of this object.

spongeh
Mar 22, 2009

BREADAGRAM OF PROTECTION

Mido posted:

I like the Haxe designer's approach to access control (not specific to const but moreso to class privacy):


:tipshat: glad to contribute nothing to the conversation

funny-internet-snipe.gif

are you using haxe for anything currently? i've taken a look around and it seems neat esp for games and stuff (since it came out of flash) but there doesn't seem to be much of an ecosystem incase i hit a wall somewhere

JewKiller 3000
Nov 28, 2006

by Lowtax

PleasingFungus posted:

eh, no, he's actually sort of right here. it's still not "pass-by-reference", but passing a pointer still means that you can mutate stuff "in" the previous function's scope. which can get messy in very obvious ways.

that is absolutely true but refer to my latest repetition on what pass by reference means

if an object is mutable and you give someone else a pointer to that object, they might mutate it through the pointer. this is definitely a serious issue, but it has NO BEARING on whether the pointer itself was passed by reference or by value, which is still an important distinction to make

Pollyanna
Mar 5, 2005

Milk's on them.


Max Facetime posted:

oooh, you are planning on tying yourself to a single-vendor ecosystem and reliving the cool 90's?

:negative: gently caress

Brain Candy
May 18, 2006

Condiv posted:

i do know the difference between the two, i just think final should make not only the reference immutable, but the members of the object it refers to.

as for why, sometimes it's nice to have some guarantees that this function, or this piece of code, or whatever, can't gently caress around with the state of this object.

i agree, i wish const did this.

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

JewKiller 3000 posted:

that is absolutely true but refer to my latest repetition on what pass by reference means

if an object is mutable and you give someone else a pointer to that object, they might mutate it through the pointer. this is definitely a serious issue, but it has NO BEARING on whether the pointer itself was passed by reference or by value, which is still an important distinction to make

he wasn't saying that passing a pointer by reference is the same as passing a pointer by value, though.

JewKiller 3000
Nov 28, 2006

by Lowtax
he literally said "passing a reference by value is equivalent to passing a value by reference", hence my objection

i know it sounds like i'm sperging out about nothing here, but that equivalence statement is simply false

JewKiller 3000
Nov 28, 2006

by Lowtax
part of the issue is that we're using the word "reference" to refer to two different things: a pointer that is exposed at the language level, and a compiler-internal aliasing of one variable name to another

uG
Apr 23, 2003

by Ralp

Pollyanna posted:

:negative: gently caress

yeah I'm sure people will be frothing at the mouth on both windows and osx to use your babby first gui program

Pollyanna
Mar 5, 2005

Milk's on them.


uG posted:

yeah I'm sure people will be frothing at the mouth on both windows and osx to use your babby first gui program

imma a be a gerat programer one day. ill be paid lots of money like $40000 dollars

Bloody
Mar 3, 2013

wait what's wrong with mutability? why should i scrap an entire object and any children objects any time anything changes?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

rust seems pretty cool but i dont want to use it (yet?)

Brain Candy
May 18, 2006

Bloody posted:

wait what's wrong with mutability? why should i scrap an entire object and any children objects any time anything changes?

some day, which may never come to pass, people are going to do something weird like strap two CPUs together in a way that they share memory in the same process. or maybe in some distant future, people will work on codebases with an absurd number on lines of code, like 100,000.

when that day comes, you will understand.

JewKiller 3000
Nov 28, 2006

by Lowtax

Bloody posted:

wait what's wrong with mutability? why should i scrap an entire object and any children objects any time anything changes?

mutability can be convenient, especially when working in imperative languages designed around assignment statements... but immutability is often desirable because it facilitates local reasoning (nobody can modify this object out from under me) and cooperates well with multithreading (you don't need locking to synchronize writes if you can't write at all)

fortunately compilers are good at dealing with the potential issue you suggest. if you have a giant object and you just want to change one field, then conceptually, at the semantic level of your programs, you are making an entire copy of the object with the field equal to the new value. however, under the hood, the compiler can simply refer to the original object for everything except the new field, essentially keeping only a diff. this is safe because the object is immutable, so you know it can never change from its state when you created the "copy"!

compilers for any language that takes pervasive immutability seriously will implement this optimization, to the extent that it is often MORE efficient to define an object as immutable if at all possible

FamDav
Mar 29, 2008

JewKiller 3000 posted:

in case another repetition helps:

when you pass a reference by value, you have two copies of the reference, one on the caller's stack, and another on the callee's stack
when you pass a value by reference, you have just one copy of the value, on the caller's stack. uses of the corresponding argument by the callee refer back to this single value on the caller's stack, and no copy is made. hence the name "pass by reference"

if this doesn't matter for your use cases so you don't care, that's fine
but you shouldn't go claiming that the two things are equivalent when the distinction between them can be very important
especially since, as we have seen in this thread, there are a lot of people with incorrect understanding of evaluation strategies

sorry, i should have clarified.

for the purposes of knowing "if i put my X into this function it cant silently modify what i consider to be X", they are equivalent.

X in this case being the object.

Bloody
Mar 3, 2013

Brain Candy posted:

some day, which may never come to pass, people are going to do something weird like strap two CPUs together in a way that they share memory in the same process. or maybe in some distant future, people will work on codebases with an absurd number on lines of code, like 100,000.

when that day comes, you will understand.

as an embedded person these days will probably not come to pass.

JewKiller 3000
Nov 28, 2006

by Lowtax

FamDav posted:

sorry, i should have clarified.

for the purposes of knowing "if i put my X into this function it cant silently modify what i consider to be X", they are equivalent.

X in this case being the object.

that's true, and your point that the distinction between pass-by-value and pass-by-reference doesn't really address this issue of object mutability is well taken. in fact, i think we mostly agree; i'm only objecting to a misuse of evaluation strategy terms which, while sounding relevant to a discussion about the values of objects, are actually describing a language's strategy for resolving argument names

FamDav
Mar 29, 2008
edited out some pointless example

JewKiller 3000 posted:

that's true, and your point that the distinction between pass-by-value and pass-by-reference doesn't really address this issue of object mutability is well taken. in fact, i think we mostly agree; i'm only objecting to a misuse of evaluation strategy terms which, while sounding relevant to a discussion about the values of objects, are actually describing a language's strategy for resolving argument names

thats cool and im sure we agree. i just dont know why you keep bringing poo poo back to some programming languages 101 poo poo just because sulk doesnt know a thing.

FamDav fucked around with this message at 03:56 on Sep 27, 2013

Adbot
ADBOT LOVES YOU

JewKiller 3000
Nov 28, 2006

by Lowtax
the reason i'm doing it is because sulk (others too) doesn't know a thing and this is the pl thread where we try to learn a thing

JewKiller 3000 fucked around with this message at 03:59 on Sep 27, 2013

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