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
BigRedDot
Mar 6, 2008

ulmont posted:

I don't disagree with your general breakdown, but when I learned OOP (also ~20 years ago), the emphasis was more about message passing between the objects than the imperative style (which is how I see structured programming).

Were you taught using Smalltalk? (genuinely curious). At least in my experience the message passing description/model/terminology was mostly confined to Smalltalk circles.

BigRedDot fucked around with this message at 18:39 on Nov 1, 2016

Adbot
ADBOT LOVES YOU

Uhh Nope
May 20, 2016
I'm relatively new to WPF and I'm developing a small WPF application for my team.

How do I style my UI elements without scaring my coworkers who are all familiar with Windows Forms land? There's so many ways to do it! UserControls, Templates, Styles, Theme.xaml(s), etc. The closest thing to it that I've ever used is CSS with HTML and over time it has become apparent to me that it is nothing like CSS.

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

BigRedDot posted:

Were you taught using Smalltalk? (genuinely curious). At least in my experience the message passing description/model/terminology was mostly confined to Smalltalk circles.

Yup.

Structured Programming: C.
OOP: Smalltalk.
Functional Programming: Lisp.
Declarative: Prolog.

ToxicFrog
Apr 26, 2008


Star War Sex Parrot posted:

It survived probably for a bit longer than it should have as a teaching language, and I had one class not too long ago where the ancient instructor's pseudocode resembled Pascal. As far as I know, it's relatively dead these days. I think Delphi might live on in some weird use cases.

I'd love someone to tell me if they've encountered Pascal in the real world lately.

DoomRL and other roguelikes written using libvalkyrie are all Pascal.

Peristalsis
Apr 5, 2004
Move along.

Star War Sex Parrot posted:

It survived probably for a bit longer than it should have as a teaching language, and I had one class not too long ago where the ancient instructor's pseudocode resembled Pascal. As far as I know, it's relatively dead these days. I think Delphi might live on in some weird use cases.

I'd love someone to tell me if they've encountered Pascal in the real world lately.

I guess it's not all that recent, but I had to work on some legacy code in Borland Pascal at a job I held from 2000 to late 2006. I think we had migrated away from the Pascal code pretty completely the last couple of years I was there. One of my first tasks at that job was fixing an error that was showing up on the newer machines trying to run the application. It turns out there was some built-in library that would try to divide by zero if it were run on any machine with a clock speed over 200 MHz. Fortunately, some sad soul had written a replacement for it, so I was able to swap in the replacement library and extend our research app's life by a few more years. I also had to replace a fixed array of structs with a linked list of the same structs in that program, to give it a bit more flexibility. That made use of more memory resources, and we could store up to 88 structs worth of info instead of the 80 the array was limited to.

It's kind of a shame that it faded away, really - I liked Pascal's syntax well enough*, but I guess it never became fashionable enough to really keep around. I think Borland extended their Pascal to include classes and objects by the end of its run, but then they discontinued that and put their full efforts into Delphi. My understanding was that Delphi was sort of a Pascal version of Visual Basic, and that people who used it loved it, but again, it never really caught on in a big way. Last I remember, Microsoft hired away the main designer of Delphi to work on C# for them. I imagine Delphi still exists, but I don't even know who owns the rights for it any more. I think Borland was sold/renamed/dissolved multiple times, so there's no telling where the legal rights ended up.


* Of course, I haven't used it in over 10 years, and might not like it so much today. Still, it doesn't seem any crazier to think of using Pascal these days than BASIC. I guess BASIC looks a little less intimidating.

Peristalsis fucked around with this message at 19:56 on Nov 1, 2016

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Star War Sex Parrot posted:

It survived probably for a bit longer than it should have as a teaching language, and I had one class not too long ago where the ancient instructor's pseudocode resembled Pascal. As far as I know, it's relatively dead these days. I think Delphi might live on in some weird use cases.

I'd love someone to tell me if they've encountered Pascal in the real world lately.

At my place we bought a smaller company and some of their several-years-old stuff used Delphi. We've not touched it or made any attempt to build it.

Due to boneheaded choices and development practices by the previous management of the company, there's a hardcoded IP address in one piece of software to a server that costs an arm and a leg to keep where it is. Thankfully there is only one customer using this software, and although they are a very important customer, we reckon we can just binary-edit the installer (which we have) to substitute a different address of our choice...

fritz
Jul 26, 2003

BigRedDot posted:


Under this taxonomy Structured Programming (which was mostly about raising the level of abstraction by advocating for codified, correctly implemented control structures) and OOP are different types of imperative programming.

I feel like structured programming won so decisively that it's hard to say what it is anymore.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

BigRedDot posted:

Were you taught using Smalltalk? (genuinely curious). At least in my experience the message passing description/model/terminology was mostly confined to Smalltalk circles.

Doesn't that describe Erlang now too?

nielsm
Jun 1, 2009



Delphi still exists as a product, but it is largely a specialty thing and I think its main use case is maintaining legacy software by now. Licenses go into the "stupid expensive" range, presumably they have to gouge the few remaining customers to keep Delphi as a product in business.

One of the interesting things about Delphi is actually that it goes a very long way to make COM programming easy and much less painful than most other languages will make it. However I never got the fundamental grasp of COM back when I did use Delphi (up until 13 years ago) so I didn't get to reap the benefits of that. But looking back at it, it seems it might be more suitable than C++ for implementing COM servers. Today C# may be a better choice for the most part, but unlike Delphi, C# COM servers will naturally force the client to have the .NET framework loaded in, or the server will have to be out-of-process.

Honestly it's not a bad language, it's verbose but the type system is quite expressive.

raminasi
Jan 25, 2005

a last drink with no ice

Uhh Nope posted:

I'm relatively new to WPF and I'm developing a small WPF application for my team.

How do I style my UI elements without scaring my coworkers who are all familiar with Windows Forms land? There's so many ways to do it! UserControls, Templates, Styles, Theme.xaml(s), etc. The closest thing to it that I've ever used is CSS with HTML and over time it has become apparent to me that it is nothing like CSS.

Ask the .NET thread!

The short answer to your question is, as usual, "it depends," but if it's a small, internal app then you probably don't need to worry about anything fancy like theming or rolling your own controls.

cloudchamber
Aug 6, 2010

You know what the Ukraine is? It's a sitting duck. A road apple, Newman. The Ukraine is weak. It's feeble. I think it's time to put the hurt on the Ukraine
Does anybody know if there's any places online which provide practical SQL challenges? Like they provide you with tables and then ask you to write statements that will return data specified by them. Is this a thing you can find anywhere?

everythingWasBees
Jan 9, 2013




I realized I was just kind of asking about non-OO imperative approaches but too tired to figure out how to phrase it, but this all gave me a whole lot of new leads so thank you all so very much!

Hughmoris
Apr 21, 2007
Let's go to the abyss!

Hammerite posted:

I picked up C# "on the job" at my current place, having been comfortable using Python before. These days I have to say I prefer using C#, though I still happily use Python for small stuff. When I have an issue with something in C# it's invariably to do with its nature as a statically typed language (which also is limited occasionally by having to conform to aspects of the .NET environment) - but being statically typed also allows confidence in places you wouldn't necessarily have it if you built a large, complex system in Python.

Some aspects of C# can be verbose compared to Python, sure, but it's not all that bad. I would say:

  • Learn to love LINQ.
  • Learn to use time-saving features of the IDE. If you find the language verbose, use the features that cut down on typing.
  • Pick up other features of the IDE gradually, as and when you need them. The Visual Studio debugger is really good - make sure to learn your way around it.

Thanks for this.

ExcessBLarg!
Sep 1, 2001

Peristalsis posted:

One of my first tasks at that job was fixing an error that was showing up on the newer machines trying to run the application. It turns out there was some built-in library that would try to divide by zero if it were run on any machine with a clock speed over 200 MHz.
Yep, that was a thing. It was a bug in the runtime for Turbo and Borland Pascals. Breaks a few DOS games and demos. There's patches for the runtime, but demos tend to use packers. Mo'Slo works though.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

everythingWasBees posted:

I realized I was just kind of asking about non-OO imperative approaches but too tired to figure out how to phrase it, but this all gave me a whole lot of new leads so thank you all so very much!

Note that OO isn't necessarily just an imperative thing. The primary tenet of OOP is "make abstract data types", i.e. you should organize your data into meaningful classes/types/whatever that encapsulate the representation and provide an abstract interface of high-level operations. Mutability makes that really critically important, but even without mutability it's still really important if you have any interest in writing good, maintainable code. Most functional languages do provide some tools for abstract data types, and some (notably OCaml) even support organizing operations into classically OO-style class-namespaced methods, all without pushing you inevitably into the world of mutability. Features like dynamic method dispatch and inheritance are really secondary, but they, too, are not at all incompatible with functional programming.

PierreTheMime
Dec 9, 2004

Hero of hormagaunts everywhere!
Buglord
I'm having a hell of a time getting a stupid date-based Regex to work properly for a simple Java assignment. It's just a generic test for yyyy-mm-dd that matches correct total days of the month, but for whatever reason the pattern is just ignoring the last digit in any date I feed in. The frustrating part is the Debuggex site shows the logic is correct in its flow chart, but the result is wrong. There's a ton of example dates in the link below for examples.

Debuggex chart: https://www.debuggex.com/r/rBt7UDZNphWSPifs

Regex:
code:
((19|20)\d{2})\-(0?[469]|1[1])\-(0?[1-9]|[12][0-9]|30)|((19|20)\d{2})\-(0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|((19|20)\d{2})\-(0?[2])\-(0?[1-9]|[12][0-9])
Any help would be greatly appreciated, as this is driving me mad.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

PierreTheMime posted:

I'm having a hell of a time getting a stupid date-based Regex to work properly for a simple Java assignment. It's just a generic test for yyyy-mm-dd that matches correct total days of the month, but for whatever reason the pattern is just ignoring the last digit in any date I feed in. The frustrating part is the Debuggex site shows the logic is correct in its flow chart, but the result is wrong. There's a ton of example dates in the link below for examples.

Debuggex chart: https://www.debuggex.com/r/rBt7UDZNphWSPifs

Regex:
code:
((19|20)\d{2})\-(0?[469]|1[1])\-(0?[1-9]|[12][0-9]|30)|((19|20)\d{2})\-(0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|((19|20)\d{2})\-(0?[2])\-(0?[1-9]|[12][0-9])
Any help would be greatly appreciated, as this is driving me mad.

The main learning point you should take away from this is that regular expressions are not the answer to every problem. Still...

- why is the year part repeated for each month-length part of the regex? Put that once at the start and stick everything else in a bracketed subpattern after it. Doing this I get: (line breaks and leading whitespace are added for readability)

code:
(
    (19|20)\d{2}
)\-(
    (0?[469]|1[1])\-(0?[1-9]|[12][0-9]|30)|
    (0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|
    (0?[2])\-(0?[1-9]|[12][0-9]
)
- you don't need "[...]" around single characters; "1[1]" can be rewritten as "11"

code:
(
    (19|20)\d{2}
)\-(
    (0?[469]|11)\-(0?[1-9]|[12][0-9]|30)|
    (0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|
    (0?2)\-(0?[1-9]|[12][0-9])
)
- you use \d in some places and [0-9] in others, which is inconsistent. I think you should use [0-9], since \d matches Unicode digit characters other than ASCII ones.

code:
(
    (19|20)[0-9]{2}
)\-(
    (0?[469]|11)\-(0?[1-9]|[12][0-9]|30)|
    (0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|
    (0?2)\-(0?[1-9]|[12][0-9])
)
- you're not checking that I haven't entered something like 2005-02-29 (2005 is not a leap year) (have fun with that!)

However, as to the problem you originally complained about, I haven't identified the problem. Post your test cases?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Looking at the linked web page... Your problem is that you're not requiring the match to be the entire string, so the regex engine opportunistically matches e.g. up to the "3" in "30" which is treated as the units digit in the first alternative group; then it ignores the rest. Try adding ^...$ to the pattern.

PierreTheMime
Dec 9, 2004

Hero of hormagaunts everywhere!
Buglord

Hammerite posted:

- you're not checking that I haven't entered something like 2005-02-29 (2005 is not a leap year) (have fun with that!)

However, as to the problem you originally complained about, I haven't identified the problem. Post your test cases?

Thanks for the input!

The leap year check is actually being handled outside of Regex in my assignment by checking the Group month/date and then doing a simple modulus check of the year if they match 0?2 and 29. I assume the professor just doesn't want to get into the weeds of coding that into Regex since this is just meant as an assignment to briefly acknowledge their use.

Hammerite posted:

Looking at the linked web page... Your problem is that you're not requiring the match to be the entire string, so the regex engine opportunistically matches e.g. up to the "3" in "30" which is treated as the units digit in the first alternative group; then it ignores the rest. Try adding ^...$ to the pattern.

Hmm. Would you mind using an example of this? I tried
code:
^((19|20)\d{2})\-(0?[469]|11)\-(0?[1-9]|[12][0-9]|30)|((19|20)\d{2})\-(0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|((19|20)\d{2})\-(0?[2])\-(0?[1-9]|[12][0-9])$
and it didn't seem to have any effect.

ToxicFrog
Apr 26, 2008


PierreTheMime posted:

The leap year check is actually being handled outside of Regex in my assignment by checking the Group month/date and then doing a simple modulus check of the year if they match 0?2 and 29. I assume the professor just doesn't want to get into the weeds of coding that into Regex since this is just meant as an assignment to briefly acknowledge their use.

If you're going to have to do semantic validation of the date after parsing it anyways, why not just do:

code:
([0-9]{4})-([0-9]{2})-([0-9]{2})
and then check that the user hasn't asked for january 56th or the third day of the 18th month in the same place you check leap year validity?

PierreTheMime
Dec 9, 2004

Hero of hormagaunts everywhere!
Buglord

ToxicFrog posted:

If you're going to have to do semantic validation of the date after parsing it anyways, why not just do:

code:
([0-9]{4})-([0-9]{2})-([0-9]{2})
and then check that the user hasn't asked for january 56th or the third day of the 18th month in the same place you check leap year validity?

Because the instructions of the assignment are to exclusively use the regex pattern with the exception of dealing with leap years, unfortunately. If I could use code this would have been done hours ago.

LLSix
Jan 20, 2010

The real power behind countless overlords

Star War Sex Parrot posted:

It survived probably for a bit longer than it should have as a teaching language, and I had one class not too long ago where the ancient instructor's pseudocode resembled Pascal. As far as I know, it's relatively dead these days. I think Delphi might live on in some weird use cases.

I'd love someone to tell me if they've encountered Pascal in the real world lately.

Pascal was pretty popular in AI research back when I was studying it about a decade ago. I haven't encountered it since.

PierreTheMime
Dec 9, 2004

Hero of hormagaunts everywhere!
Buglord
Pattern completed with a little help from a coworker. I hope to never touch more than basic regex again for a long time.

code:
((19|20)\d{2})\-((0?[469]|1[1])\-([12]{1}[0-9]{1}|30|(?![3-9]{1}[1-9]{1})0?[1-9])|(0?[13578]|1[02])\-([12]{1}[0-9]{1}|3[01]|(?![3-9]{1}[2-9]{1})0?[1-9])|(0?[2])\-([12]{1}[0-9]{1}|(?![3-9]{1}[2-9]{1})0?[1-9]))
Here's the leap year check, for completeness sake:
code:
Matcher dateMatch = m_datePattern.matcher(input);
if (dateMatch.find()) {
	if ((dateMatch.group(8)!=null) ) {
		int year = Integer.parseInt(dateMatch.group(1));
		return ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0));
	}
}

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

PierreTheMime posted:

Thanks for the input!

The leap year check is actually being handled outside of Regex in my assignment by checking the Group month/date and then doing a simple modulus check of the year if they match 0?2 and 29. I assume the professor just doesn't want to get into the weeds of coding that into Regex since this is just meant as an assignment to briefly acknowledge their use.


Hmm. Would you mind using an example of this? I tried
code:
^((19|20)\d{2})\-(0?[469]|11)\-(0?[1-9]|[12][0-9]|30)|((19|20)\d{2})\-(0?[13578]|1[02])\-(0?[1-9]|[12][0-9]|3[01])|((19|20)\d{2})\-(0?[2])\-(0?[1-9]|[12][0-9])$
and it didn't seem to have any effect.

You might need to make it ^(...)$ rather than ^...$

Also, it seemed to me like that site was trying to treat the entire contents of the text box as the string to be matched, rather than substrings in quotes.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
Does anybody have any experience creating/importing new tasks into windows Task Scheduler using .xml files?

My problem: I've written a script in python and compiled to .exe so I can share it with people who don't have Python installed. However, this program needs to be run 1x every hour, ad infinitum. If I automatically create a task using batch, such as:

code:
set filepath=%cd%
schtasks /create /tn "TestShit" /tr "\"%filepath%\run.exe\"" /sc HOURLY /st 00:59
It doesn't work, as there's no way of setting the "Start in (optional)" field, which is apparently not so optional after all. There are also various other settings you can't edit using "schtasks" which are quite important for my program.

One solution is to export the task you want to a .xml file, then reimport that using a .bat file. Great, only there are several variables which need to be configured for each person's computer and I have no idea how to do that.

I could import the .xml into Python, generate the values, then import it in via .bat, but I have no idea how to get the values for:

<RegistrationInfo><Author> (which looks like: PC-Desktop\Tom)

<Principals> <Principal id="Author"> <UserId> (which looks like: S-1-5-21-2071512246-1631738662-3274286287-1001 -- I don't know what this value actually signifies so I changed a few digits)

Does anybody know a relatively easy way to overcome this problem? I guess I could bundle it with a 3rd party scheduling daemon and automatically copy a shortcut to that into the startup folder somehow.. but there's got to be some way of automatically configuring a task scheduler .xml file to the current user.

nielsm
Jun 1, 2009



Sulla-Marius 88 posted:

Does anybody have any experience creating/importing new tasks into windows Task Scheduler using .xml files?

My problem: I've written a script in python and compiled to .exe so I can share it with people who don't have Python installed. However, this program needs to be run 1x every hour, ad infinitum. If I automatically create a task using batch, such as:

code:
set filepath=%cd%
schtasks /create /tn "TestShit" /tr "\"%filepath%\run.exe\"" /sc HOURLY /st 00:59
It doesn't work, as there's no way of setting the "Start in (optional)" field, which is apparently not so optional after all. There are also various other settings you can't edit using "schtasks" which are quite important for my program.

One solution is to export the task you want to a .xml file, then reimport that using a .bat file. Great, only there are several variables which need to be configured for each person's computer and I have no idea how to do that.

I could import the .xml into Python, generate the values, then import it in via .bat, but I have no idea how to get the values for:

<RegistrationInfo><Author> (which looks like: PC-Desktop\Tom)

<Principals> <Principal id="Author"> <UserId> (which looks like: S-1-5-21-2071512246-1631738662-3274286287-1001 -- I don't know what this value actually signifies so I changed a few digits)

Does anybody know a relatively easy way to overcome this problem? I guess I could bundle it with a 3rd party scheduling daemon and automatically copy a shortcut to that into the startup folder somehow.. but there's got to be some way of automatically configuring a task scheduler .xml file to the current user.

Rewrite your tool in PowerShell and use the New-ScheduledTask and family cmdlets to set it up.
If you're careful and only use PowerShell 2.0 syntax and features, you're guaranteed anyone with Windows 7 and up can run it, although you'd have to add a digital signature to the script to let them run it without first changing execution policy. (Or you can work around that by launching the script via a batch file that temporarily uses another execution policy.)

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I have a really basic question about *-devel packages (at least on CentOS/RHEL): basically what are they? For example if I look at BLAS I see the following:

code:
blas-devel.x86_64 : BLAS development libraries
blas-static.x86_64 : BLAS static libraries
blas.x86_64 : The Basic Linear Algebra Subprograms library
From my understanding, the devel branches contains things like .h header files etc that I need if I want to use BLAS in my programs or compile/link programs against it. I guess what I don't understand is there a difference between blas and blas-devel? I can't really imagine a situation where I wouldn't need the header/include files but maybe I'm just not thinking outside my box.

The second question is, if I do a yum/dnf install blas-devel, do I also need to install blas as well?

Third question is something I just noticed when writing this. What is the static library? I've seen other packages have a static package too.

nielsm
Jun 1, 2009



The "blas" package contains the dynamically linked runtime libraries. You need this to run a program that links dynamically against BLAS.
The "blas-devel" package contains the headers required to compile a program against the BLAS library. Only required to compile programs, not to run them.
The "blas-static" package contains libraries for linking statically to, when compiling programs. Only required to compile programs, not to run them.

If you don't know the difference between static and dynamic linking, you should read up on that.
The simplified version is, static linking includes the complete code of the library into the main executable for the program. The static library is only required during build. Dynamic linking only inserts a reference to the library files and function names during build, and the OS loader then builds an in-memory image combining the main binary and the dynamic libraries. The dynamic libraries are required both during build and during runtime.

Linear Zoetrope
Nov 28, 2011

A hero must cook
It depends to some degree on the exact build environment. A lot of C or C++ programs/libraries tend to require headers naming the BLAS functions they're linking to and need devel. You could specify or package in your own BLAS headers, of course, when distributing your library's source. This is also kind of how Python's C FFI bindings work, where you have to manually specify the functions signatures in Python, meaning you only need the .dll/.so/.dylib/.a file because you're essentially providing your own header and it's simply searching for the functions in the library at link time (when you call cdll.LoadLibrary generally). Rust's FFI works similarly.

In most cases, anything you find in yum/pacman/apt-get will be linked dynamically, but there are exceptions, hence why the static variant often gets a special listing.

Also, for BLAS specifically probably build OpenBLAS yourself. The one on apt-get tends to have iffy performance.

nielsm posted:

Dynamic linking only inserts a reference to the library files and function names during build, and the OS loader then builds an in-memory image combining the main binary and the dynamic libraries. The dynamic libraries are required both during build and during runtime.

Depends on the environment I think. I've certainly had programs succeed at building when I had a malformed or misplaced dll/so, but then die at runtime.

Linear Zoetrope fucked around with this message at 13:07 on Nov 7, 2016

BigRedDot
Mar 6, 2008

rjmccall posted:

Note that OO isn't necessarily just an imperative thing. The primary tenet of OOP is "make abstract data types", i.e. you should organize your data into meaningful classes/types/whatever that encapsulate the representation and provide an abstract interface of high-level operations. Mutability makes that really critically important, but even without mutability it's still really important if you have any interest in writing good, maintainable code. Most functional languages do provide some tools for abstract data types, and some (notably OCaml) even support organizing operations into classically OO-style class-namespaced methods, all without pushing you inevitably into the world of mutability. Features like dynamic method dispatch and inheritance are really secondary, but they, too, are not at all incompatible with functional programming.

This is why I think the taxonomy I learned is still the most useful. OOP can be done in imperative or functional languages. Similarly structured programming is about flow control (i.e. no writing your own while loops by hand with gotos) and that's perfectly fine for imperative or functional too. In fact, I think I'd refine my earlier descriptions:
  • imperative - explicit control flow, explicit state management
  • functional - explicit control flow, but no explicit state management
  • logical - neither explicit control flow, nor explicit state management
Which has the benefit of being comprehensive, but also non-overlapping. Although now it makes me wonder what a language with explicit state management but no explicit flow control might be or look like. "Mathematical"? Thinking of APL, perhaps, where array operations are vectorized, obviating the need for explicit loops.

BigRedDot fucked around with this message at 05:39 on Nov 8, 2016

Computer Serf
May 14, 2005
Buglord
Is there language agnostic terminology for "indirectly inheriting a value from an upstream variable still does not imply z = x" in the case of:

code:
define variable x = foo
define variable y = x
define variable z = y

z !=x
Even though x & z both = foo, and z is inheriting a value (indirectly) from x.

Is this just an issue of semantics and useless desire for an inherent rationality of a language architecture? :negative:

edit:
Or is this a stupid thing to ask for of a variable, and instead using classes?

Computer Serf fucked around with this message at 07:02 on Nov 8, 2016

raminasi
Jan 25, 2005

a last drink with no ice

Computer Serf posted:

Is there language agnostic terminology for "indirectly inheriting a value from an upstream variable still does not imply z = x" in the case of:

code:

define variable x = foo
define variable y = x
define variable z = y

z !=x

Even though x & z both = foo, and z is inheriting a value (indirectly) from x.

Is this just an issue of semantics and useless desire for an inherent rationality of a language architecture? :negative:

edit:
Or is this a stupid thing to ask for of a variable, and instead using classes?

Can you ask your question with respect to a specific language? Your attempt to extract an abstract concept was overzealous, and as a result, you've kind of invented your own definitions for things that make answering you basically impossible.

Xerophyte
Mar 17, 2008

This space intentionally left blank
I am going to invent the term nontransitive assignment (©, ™, pat. pend.) for this concept. I'm sure it's a totally original idea, please do not steal.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

Computer Serf posted:

Is there language agnostic terminology for "indirectly inheriting a value from an upstream variable still does not imply z = x" in the case of:

code:
define variable x = foo
define variable y = x
define variable z = y

z !=x
Even though x & z both = foo, and z is inheriting a value (indirectly) from x.

Is this just an issue of semantics and useless desire for an inherent rationality of a language architecture? :negative:

edit:
Or is this a stupid thing to ask for of a variable, and instead using classes?

It's not the most logical thing to ask for because transitivity is definitely what anyone reading your code expects of the equals sign. Also, classes are not an alternative to variables, they are concepts that are used together. A variable might have a type that is a class.

I think what you want to do is distinguish two variables which have equivalent values. In some languages, you can do this by checking if the variables are in fact references to the same object/location in memory. So in C:

C++ code:
 
double x = 0;
double y = x;

&x != &y //true
x == y //true

Computer Serf
May 14, 2005
Buglord

Fergus Mac Roich posted:

It's not the most logical thing to ask for because transitivity is definitely what anyone reading your code expects of the equals sign. Also, classes are not an alternative to variables, they are concepts that are used together. A variable might have a type that is a class.

I think what you want to do is distinguish two variables which have equivalent values. In some languages, you can do this by checking if the variables are in fact references to the same object/location in memory. So in C:

C++ code:
 
double x = 0;
double y = x;

&x != &y //true
x == y //true

Ah thanks! Object/location memory allocation would effectively confine the thingies.
Hopefully :eng99:


raminasi posted:

Can you ask your question with respect to a specific language? Your attempt to extract an abstract concept was overzealous, and as a result, you've kind of invented your own definitions for things that make answering you basically impossible.

How to define a variable z that may sometimes equal x, while distinguishing that x is not z. It's somewhat a silly exercise maybe, but it struck my curiosity because I had recently gone through a book on language and faulty logic where logical assumptions were mentioned and I was wondering if this was common or thought of already in any sort of programming language architecture. Explicit memory allocation would be effective, it seems.

Computer Serf fucked around with this message at 19:56 on Nov 8, 2016

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Yeah, Fergus Mac Roich said what I would've said -- compare the memory used by the variables. The code you described has the variables containing copies of the same data, but those copies will be in different locations in memory. If they were in the same location in memory, then the two variables would be aliases of each other.

I...can't think of any languages that let you make a variable that's a straight alias of another variable. There has to be some kind of explicit memory shenanigans going on. That is, you can say "I have variable X stored at location Y, and I can write to Y to change the value of X", but you can't say "I have variable X stored at Y, and I have variable Z also stored at Y". You can easily have X and Z whose values are both Y, but those values aren't both stored at Y.

I think I'm doing a bad job of explaining this. :negative:

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

TooMuchAbstraction posted:

Yeah, Fergus Mac Roich said what I would've said -- compare the memory used by the variables. The code you described has the variables containing copies of the same data, but those copies will be in different locations in memory. If they were in the same location in memory, then the two variables would be aliases of each other.

I...can't think of any languages that let you make a variable that's a straight alias of another variable. There has to be some kind of explicit memory shenanigans going on. That is, you can say "I have variable X stored at location Y, and I can write to Y to change the value of X", but you can't say "I have variable X stored at Y, and I have variable Z also stored at Y". You can easily have X and Z whose values are both Y, but those values aren't both stored at Y.

I think I'm doing a bad job of explaining this. :negative:

C++ references?

code:

int x = 3;
int &y = x;
++y; // Changes x

Eela6
May 25, 2007
Shredded Hen

Computer Serf posted:

Ah thanks! Object/location memory allocation would effectively confine the thingies.
Hopefully :eng99:


How to define a variable z that may sometimes equal x, while distinguishing that x is not z. It's somewhat a silly exercise maybe, but it struck my curiosity because I had recently gone through a book on language and faulty logic where logical assumptions were mentioned and I was wondering if this was common or thought of already in any sort of programming language architecture. Explicit memory allocation would be effective, it seems.

Python separates is and equals, and allows true aliasing.

x = [2]
y = x
z = [2]

x == y #true
x == z #true
x is y # true
x is z #false

Stinky_Pete
Aug 16, 2015

Stinkier than your average bear
Lipstick Apathy
To clarify syntax and terms,


code:
int* x;
(*x) = 20;
int  y;
y = 20;
*x == y
x != &y
read the last line as "x is not equal to the address of y"
read the line above it as "the value at address x is equal to y"

and then we can have
code:
x = &y;
y = 10;
*x == 10

Stinky_Pete fucked around with this message at 20:23 on Nov 8, 2016

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Computer Serf posted:

Ah thanks! Object/location memory allocation would effectively confine the thingies.
Hopefully :eng99:
orig code:
code:
define variable x = foo
define variable y = x
define variable z = y

z !=x
How "agnostic" are we talking here? In a multithreaded environment, there's nothing stopping you from getting switched out after assigning x and y, having someone else muck up the memory for y, then switching back in for the final assignment and having z!=x.

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