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
Standish
May 21, 2001

quote:

if ($_POST[$field])
This does not ensure that $_POST[$field] is an array.

Adbot
ADBOT LOVES YOU

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Does anyone have recommendations for a programmer-friendly hosting service? I primarily want to try writing a small client/server setup in .NET and put the server part up somewhere that I can connect to from wherever. This is mainly a learning project since I've never done anything cross-network before so it wouldn't need any fancy bandwidth/storage/cpu specs, but if they had database access of some kind and maybe FTP or web page hosting that'd be cool.

I just finished participating in the SA GameDev competition, and a lot of the other entries feature high-score leaderboards. I realized that I have no clue how to do that kind of thing but that would be a good first target application.

Any book recommendations for this kind of programming would be great too, especially if it came from a .NET angle for the non-fundamentals parts.

shrughes
Oct 11, 2008

(call/cc call/cc)

PDP-1 posted:

Does anyone have recommendations for a programmer-friendly hosting service? I primarily want to try writing a small client/server setup in .NET and put the server part up somewhere that I can connect to from wherever. This is mainly a learning project since I've never done anything cross-network before so it wouldn't need any fancy bandwidth/storage/cpu specs, but if they had database access of some kind and maybe FTP or web page hosting that'd be cool.

Just get a cheap VPS at prgmr.com and run whatever you... Windows :(

Just get a cheap VPS at prgmr.com and write a bunch of .NET stuff that runs on Mono, use whatever Unix-supporting database you want, have fun.

Or get a VPS that runs Windows somewhere that hosts such things. It will be more expensive due to licensing, and it will probably suck.

By the way, you don't really want FTP hosting, so just forget about that.

duck monster
Dec 15, 2004

PDP-1 posted:

Does anyone have recommendations for a programmer-friendly hosting service? I primarily want to try writing a small client/server setup in .NET and put the server part up somewhere that I can connect to from wherever. This is mainly a learning project since I've never done anything cross-network before so it wouldn't need any fancy bandwidth/storage/cpu specs, but if they had database access of some kind and maybe FTP or web page hosting that'd be cool.

I just finished participating in the SA GameDev competition, and a lot of the other entries feature high-score leaderboards. I realized that I have no clue how to do that kind of thing but that would be a good first target application.

Any book recommendations for this kind of programming would be great too, especially if it came from a .NET angle for the non-fundamentals parts.

Find a vhost provider that does windows. Won't be cheap compared to linux, but hey, at least your not trying to write a server in Cocoa. I don't even know if mass hosted mac vhosts even exist. But yeah, its always going to be more expensive in windows, because frankly windows just isn't good at being squeezed into resource constrained spaces like you can do with linux (by just stripping poo poo out till it fits comfortably), and any host has to pay licencing fees.

Interestingly however once you go up the scale the difference in price isnt too much different. Microsoft are not stupid and your vhost provider isn't paying store prices for win server , but rather they tend to have fancy negotiated licencing plans with microsoft that make it economical for them. MS knows full well any sale is better than no sale, and adjusts accordingly.

It will be interesting to see how microsoft reacts to the interest being shown by the datacenter world towards ARM as a possible future, as the biggest issue datacenters have is heat and power, and ARM currently murders intel on this front. The ability to make a 1U server thats basically a tiny lunchbox of micro blade servers running scaled back "appliance" OS's+server software would be a loving killer in this space, and if Win8 can deliver a cut down appliance server version for arm, it will allow for very cheap hosting that can do dot net. But that future aint quite here yet.

duck monster fucked around with this message at 05:54 on Aug 3, 2011

duck monster
Dec 15, 2004

I'm currently having a giant annoyance with eclipse where the tabs at the top only seem to show the last segment of the directory and not the filename, and I have to hover over the tab to get the file name. This is using PyDev for django work.

Ie a file called /project/appname/views.py will just say appname in the tab, which is annoying since if I've got 5 tabs all in the appname directory its just five tabs saying appname.

It didn't used to do this, and I'm stuffed if I can work out what I've changed.

Anyone know how to fix this?

Pointless Metaphor
Jan 13, 2009

Standish posted:

This does not ensure that $_POST[$field] is an array.

Thanks to this post, I just learned about is_array(). Thanks for your help!

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
Say I declare two classes, A and B, and A has an instance of B as a field. What would I call A in this relationship? Typing "the x utilizing this instance" in my documentation or whatever is tiring and messy. Parent? Encapsulator?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Perhaps "Owner"? "Parent" is already used to indicate inheritance. "Encloser" could work, but "Enclosing class" is taken to mean a class which contains an innner class definition, as in Java.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
In UML speak this is called Aggregation.

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much
So you would say that A composes or aggregates (based on the situation) the instance of B? Thanks much.

I realize this is a mundane question but when I do get around to commenting I get pretty OCD about it, partly because I hate looking at stuff a week later and not know what the hell I did.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Another term for composition is a "has-a" relationship (as opposed to the "is-a" relationship of inheritance.) You might get some results with that, although I do admit it's really generic for a search string.

CrazyBumFungus
Apr 21, 2006
Fellow humans fluent in machine speak, I beseech thee!

For someone who has a very novice level of coding experience, what would be the easiest and most efficient way to install a batch of programs with a single click on an XP/W7 machine???

I'm playing interim sysadmin at a small business and I need to be able to setup windows machines fast and efficiently. I'm not terribly familiar with programming in general, but I'd love to learn how to program things such as windows installers and what-not. What would y'all recommend?

TasteMyHouse
Dec 21, 2006

CrazyBumFungus posted:

Fellow humans fluent in machine speak, I beseech thee!

For someone who has a very novice level of coding experience, what would be the easiest and most efficient way to install a batch of programs with a single click on an XP/W7 machine???

I'm playing interim sysadmin at a small business and I need to be able to setup windows machines fast and efficiently. I'm not terribly familiar with programming in general, but I'd love to learn how to program things such as windows installers and what-not. What would y'all recommend?


You should probably use something designed for this task, like this.

Graviton v2
Mar 2, 2007

by angerbeet
Anyone have any experience with the NSIS installation scripting language?

This is it: http://nsis.sourceforge.net/Main_Page

Im getting a loving weird bug in this thing which is totally doing my head in and ive made no progress after banging my head against the wall all morning!

Basically ive got an install script made by a previous developer, in the process of adding a couple of things to it ive noticed its doing something very strange. Its control flow is for no apparent reason pissing off to another place in the script.

The easiest way ive found so far of following how this thing works is by sticking message boxes in it like the below syntax:
code:
  MessageBox MB_OK|MB_ICONEXCLAMATION  "z1"
Now in this bit below of the script, taken from the actual source (with names changed to protect the innocent):

code:
  MessageBox MB_OK|MB_ICONEXCLAMATION  "Installation of bag of bollocks aborted due to failure to install Pywin."
  Quit
  .ok:
  MessageBox MB_OK|MB_ICONEXCLAMATION  "z1"
  CreateDirectory "$SMPROGRAMS\BagOfBollocksDirectory"
  MessageBox MB_OK|MB_ICONEXCLAMATION  "z2"
SectionEnd

Section -AdditionalIcons
  MessageBox MB_OK|MB_ICONEXCLAMATION  "z3"
Control flow will never reach z3, it buggers back off to some place near the top of the script to a seemingly arbitrary location and re-installs all the files again. Once its done that flow will happily proceed to z3. This was apparently never noticed because it still works, but because of something ive added I cant have it doing that anymore because im doing a simple bit of logic somewhere else to check for a registry key.

Now before anyone says hey stupid, there is quite clealy a SectionEnd before z3, sections in the NSIS scripting language are not methods or functions, they are just ways of splitting the script up into nicely named chunks. Control flow will pass straight from one to another (apart from in this loving case!)

I cant post the whole script, not really mine to post.

Ive tried:
Reading the gently caress out of the documentation.
Commenting out all my changes, still does the same thing.
Checking for a new version of NSIS in case of bug in it, hasnt been a release since 2009.

Frankly im at my wits end, this should be an easy change goddamit! Im close telling the boss he might actually have to buy a copy of installshield express or something instead of doing everything with loving freeware!

If anyone knows what the hell is going on here, please tell me and I would be enternally greatfull, i'll post you a jar of Tiptree Jam http://www.tiptree.com/ , widely regarded as the best jam in the world!

Rick Rickshaw
Feb 21, 2007

I am not disappointed I lost the PGA Championship. Nope, I am not.
Documentation. Everyone hates it, but it's in most cases a necessity in any job. Well, anyone who is a techie and hates documentation would hate to be in my situation. Without going into too many details, I'm forced to document a system that I didn't build, and I also don't have access to. Consultants build, maintain, upgrade, and enhance the system. I don't know what's going on, and they don't provide any documentation unless asked, and even then it's something generated from MySQL Workbench in 2 minutes.

Sorry, I digress. Needless to say, in order to avoid getting fired, I need to do this documentation. I'm looking for some good documentation examples on documenting web applications, right from the hardware on up. I have Visio, but I lack the creativity to get started. If this was something that I built, I feel I would have better luck without needing to rely on samples.

Graviton v2
Mar 2, 2007

by angerbeet

Rick Rickshaw posted:

Documentation. Everyone hates it, but it's in most cases a necessity in any job. Well, anyone who is a techie and hates documentation would hate to be in my situation. Without going into too many details, I'm forced to document a system that I didn't build, and I also don't have access to. Consultants build, maintain, upgrade, and enhance the system. I don't know what's going on, and they don't provide any documentation unless asked, and even then it's something generated from MySQL Workbench in 2 minutes.

Sorry, I digress. Needless to say, in order to avoid getting fired, I need to do this documentation. I'm looking for some good documentation examples on documenting web applications, right from the hardware on up. I have Visio, but I lack the creativity to get started. If this was something that I built, I feel I would have better luck without needing to rely on samples.
If you PM your email address i'll email you some I wrote a couple of days ago for some software I wrote based on a previous devs work, its a nice template I think. It isnt exactly a web app but simalar. I can also send you some documentation on the web API the software I wrote was based on which I wrote the documentation for which is also a nice template but a little lacking in detail imo, but still a nice template/layout.

You could have a bash at changing the headings to something relevant and filling in the sections.

Taima
Dec 31, 2006

tfw you're peeing next to someone in the lineup and they don't know
Hi friends, I have a question if anyone would be kind enough to answer it (web development related):

I mainly work in HTML/CSS/Jquery with some PHP thrown in. I barely even know where to start so I'll lay out the problem first.

My company manufactures products (mostly) for professional clients, who then go on to sell to end users. I work in a relatively small industry so I would rather not elaborate further.

Anyways the issue is this: there are some legitimate reasons for an end user to create an account on our site to buy certain items, but this tends to upset our professional clients occasionally as an end user will see a price for a given item on our site and question the admittedly much higher resale price that they are being quoted by our professional clients.

So basically I am looking for a way to show prices on our website based on the privileges associated with an account. We use MySQL to handle account details, so if we could use a method that pulls directly off MySQL would probably be ideal, but who knows I am no expert. Our back end is written in ASP/VBscript, if that helps, although I would like to bypass that system and have a standalone app that queries our database.

My apologies if anything in this post seems "tech lite", I have little experience in this kind of development.

Carthag Tuek
Oct 15, 2005

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



Taima posted:

Hi friends, I have a question if anyone would be kind enough to answer it (web development related):

I mainly work in HTML/CSS/Jquery with some PHP thrown in. I barely even know where to start so I'll lay out the problem first.

My company manufactures products (mostly) for professional clients, who then go on to sell to end users. I work in a relatively small industry so I would rather not elaborate further.

Anyways the issue is this: there are some legitimate reasons for an end user to create an account on our site to buy certain items, but this tends to upset our professional clients occasionally as an end user will see a price for a given item on our site and question the admittedly much higher resale price that they are being quoted by our professional clients.

So basically I am looking for a way to show prices on our website based on the privileges associated with an account. We use MySQL to handle account details, so if we could use a method that pulls directly off MySQL would probably be ideal, but who knows I am no expert. Our back end is written in ASP/VBscript, if that helps, although I would like to bypass that system and have a standalone app that queries our database.

My apologies if anything in this post seems "tech lite", I have little experience in this kind of development.

I'm not sure I understand what your question is. I mean, I understand that you want to show different prices depending on the users privileges, but that is basically how you do it: You assign privileges to users, and then show the prices depending on the privileges.

The simplest would be to use groups. Set up a number of groups (clients, endusers, etc). Associate the users with the groups as appropiate. Then in the code that fetches the prices, have it select different sets of prices depending on what group the user is in.

Carthag Tuek
Oct 15, 2005

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



A question of my own: I have a list of names, which has a bunch of annoying duplicates. I have succesfully grouped the duplicates into sets, and I now want to merge them into the "best" one.

Constructed example of such a duplicate set:
1. Juergen Mueller
2. Jürgen Mueller
3. Jürgen Müller <- best
4. Jurgen Muller

Assuming I have a method that can perfectly translate unicode strings to their canonical ASCII representations (ie. "Jürgen" => "Juergen"), I'm thinking about doing it this way (pseudocode):

code:
sort dupes by jaro_winkler(canonical_ascii(name), name)
best = pop first element off dupes
merge rest of dupes into best
Jaro-Winkler is the distance between two strings, expressed as a float from 0.0 to 1.0 where 1.0 means identical. Thus the lower the Jaro-Winkler distance, the more different the strings are, thus the first element in a list sorted by Jaro-Winkler this way is a list of the names in the order of the most to the least different from their canonical ASCII version.

In other words, the above example ends up like this:
1. Jürgen Müller (Jaro-Winkler: 0.785454545455) <- best!
2. Jürgen Mueller (Jaro-Winkler: 0.804615384615)
3. Jurgen Muller (Jaro-Winkler: 0.882393162393)
4. Juergen Mueller (Jaro-Winkler: 1.0)

I've done some preliminary tests, and it seems to give correct results, but I can't figure out if it'll be accurate enough to run unattended (there are 1.5m+ records in total, so I wouldn't want it to poo poo all over them).

Edit: Also if anyone can recommend good books on record linkage/pattern recognition/duplicate searches/etc, that would be awesome.

Carthag Tuek fucked around with this message at 21:44 on Aug 5, 2011

Taima
Dec 31, 2006

tfw you're peeing next to someone in the lineup and they don't know

Carthag posted:

I'm not sure I understand what your question is. I mean, I understand that you want to show different prices depending on the users privileges, but that is basically how you do it: You assign privileges to users, and then show the prices depending on the privileges.

The simplest would be to use groups. Set up a number of groups (clients, endusers, etc). Associate the users with the groups as appropiate. Then in the code that fetches the prices, have it select different sets of prices depending on what group the user is in.

Thanks, I do understand that in a general sense, but what would be a good direction to write or utilize an app that a user could input their login credentials, then it would display the prices after checking if the user had the correct group? I would prefer if it was a self-contained app that could be deployed to individual pages as needed.

Sorry if I'm being stupid, I am so far outside of my comfort zone on this it's ridiculous, but that's the best way to learn I suppose :)

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Taima posted:

Thanks, I do understand that in a general sense, but what would be a good direction to write or utilize an app that a user could input their login credentials, then it would display the prices after checking if the user had the correct group? I would prefer if it was a self-contained app that could be deployed to individual pages as needed.

Sorry if I'm being stupid, I am so far outside of my comfort zone on this it's ridiculous, but that's the best way to learn I suppose :)

It depends on how the prices differ. So you have 'your' prices correct? The problem I see is that you probably don't have all of your professional clients prices (are they all the same? or does vendor A charge $X and vendor B charge $Y?). The way I see it there's a a couple options:
1. Show your prices, but scale them all up a quasi-ridiculous degree so they're always higher than your professional clients (e.g. on the page display price*1.5). You could do this on the database side as well if you want; you'd probably want multiple stored procedures like:
Products_SelectBasePrice()
and
Products_SelectPublicPrice()

and you would call a different one depending on what login account/type the user had.

From a logic perspective you'd have to add a check on every page that contains prices. The problem is your question is a bit generic, so there's tonnes of different solutions.

For example you could modify whatever gets the price, to include the user id/group id, e.g. GetPrice(ProductID,GroupLevel) and then that function could decide which price to send back.

Or, you could have a permission check on every page that sets a boolean, e.g.
If GroupLevel IN (5,16,33) then
CanSeePrices=True
(this is a bad idea by the way since it means you have to define the 'good' group ids on the page).

Sorry if this seems a bit disorganized, but there are literally dozens of solutions.

tef
May 30, 2004

-> some l-system crap ->

Carthag posted:

A question of my own: I have a list of names, which has a bunch of annoying duplicates. I have succesfully grouped the duplicates into sets, and I now want to merge them into the "best" one.

Constructed example of such a duplicate set:
1. Juergen Mueller
2. Jürgen Mueller
3. Jürgen Müller <- best
4. Jurgen Muller

Assuming I have a method that can perfectly translate unicode strings to their canonical ASCII representations (ie. "Jürgen" => "Juergen"), I'm thinking about doing it this way (pseudocode):

code:
sort dupes by jaro_winkler(canonical_ascii(name), name)
best = pop first element off dupes
merge rest of dupes into best
Jaro-Winkler is the distance between two strings, expressed as a float from 0.0 to 1.0 where 1.0 means identical. Thus the lower the Jaro-Winkler distance, the more different the strings are, thus the first element in a list sorted by Jaro-Winkler this way is a list of the names in the order of the most to the least different from their canonical ASCII version.

In other words, the above example ends up like this:
1. Jürgen Müller (Jaro-Winkler: 0.785454545455) <- best!
2. Jürgen Mueller (Jaro-Winkler: 0.804615384615)
3. Jurgen Muller (Jaro-Winkler: 0.882393162393)
4. Juergen Mueller (Jaro-Winkler: 1.0)

I've done some preliminary tests, and it seems to give correct results, but I can't figure out if it'll be accurate enough to run unattended (there are 1.5m+ records in total, so I wouldn't want it to poo poo all over them).

Edit: Also if anyone can recommend good books on record linkage/pattern recognition/duplicate searches/etc, that would be awesome.

see also: megaphone/soundex and Unicode normalisation to strip non ASCII chars,

Google refine is also good for cleaning data

Carthag Tuek
Oct 15, 2005

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



tef posted:

see also: megaphone/soundex and Unicode normalisation to strip non ASCII chars,

Google refine is also good for cleaning data

Metaphone and soundex are good for identifying likely duplicates, but I already have that part mostly accomplished. I'm basically looking for a way to identify the "best" of a given set of duplicates that will become the "true" record, and doing so in the most automatic way possible.

Hence the "longest distance from ascii-representation" method that I'm currently looking at.

I guess I'll have to either a) accept false positives, or b) make the algorithm stricter and then sift through the "likelies" by hand.

Graviton v2
Mar 2, 2007

by angerbeet
code:
def removeNonAscii(s): return "".join(i for i in s if ord(i)<128)

def somewhereelse:
#Replace right leaning ' with ascii one
details = details.replace(u'\u2019', u'\u0027')
#Remove all other high ascii characters
details = removeNonAscii(details)
:)

Carthag Tuek
Oct 15, 2005

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



Sorry, I guess I was a bit vague.

I have a method of turning unicode into ascii. I also have identified likely duplicates. I describe a method for finding the "best" candidate among a number of duplicates, and I would like to hear some thoughts on the soundness of this method.

Graviton v2
Mar 2, 2007

by angerbeet

Carthag posted:

Sorry, I guess I was a bit vague.

I have a method of turning unicode into ascii. I also have identified likely duplicates. I describe a method for finding the "best" candidate among a number of duplicates, and I would like to hear some thoughts on the soundness of this method.
Ah well thats a bit of mission isnt it. You are going to have to assign a logicly calculted threashold number, make up all the setup poo poo, and .... sorry man im tired, good with luck that.

Nippashish
Nov 2, 2005

Let me see you dance!

Carthag posted:

Sorry, I guess I was a bit vague.

I have a method of turning unicode into ascii. I also have identified likely duplicates. I describe a method for finding the "best" candidate among a number of duplicates, and I would like to hear some thoughts on the soundness of this method.

Your approach is reasonable if "best" means "longest distance from ascii-representation", but of course that's entirely circular.

You haven't said what constitutes "best", so your question is unanswerable. If your question is really "what criteria should I use to determine best" then it's still unanswerable because no one here knows enough about your system to tell you that.

raminasi
Jan 25, 2005

a last drink with no ice
Does anyone have any experience with Enclojure? I can't for the life of me figure out how to get it to understand dependencies in any kind of useful manner (I add them to the dependencies list, and I can download them, but actually getting them to go somewhere that the REPL can find them is hit-or-miss at best).

Taima
Dec 31, 2006

tfw you're peeing next to someone in the lineup and they don't know

Scaramouche posted:

Helpful Information

Excuse not responding for a moment, weekend and all. I appreciate that you took time out to write this and it will provide some good leads on how to solve my issue. Thanks.

Carthag Tuek
Oct 15, 2005

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



Nippashish posted:

Your approach is reasonable if "best" means "longest distance from ascii-representation", but of course that's entirely circular.

You haven't said what constitutes "best", so your question is unanswerable. If your question is really "what criteria should I use to determine best" then it's still unanswerable because no one here knows enough about your system to tell you that.

Yeah it's a bit of a lovely situation, since "best" is an entirely made up quality. I guess I'll try this method in a non-destructive manner and then see if it works out before finalizing the change.

TasteMyHouse
Dec 21, 2006

Carthag posted:

Yeah it's a bit of a lovely situation, since "best" is an entirely made up quality. I guess I'll try this method in a non-destructive manner and then see if it works out before finalizing the change.

what would constitute "working out"?

Carthag Tuek
Oct 15, 2005

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



TasteMyHouse posted:

what would constitute "working out"?

No complaints from the top floor.

Graviton v2
Mar 2, 2007

by angerbeet
I honestly think what you are looking for is a sort of threshold level of 'bad'. That you can set and play with if that makes sense. How you define that and even what you derive it from is hard to tell.

Nippashish
Nov 2, 2005

Let me see you dance!

Graviton v2 posted:

I honestly think what you are looking for is a sort of threshold level of 'bad'. That you can set and play with if that makes sense. How you define that and even what you derive it from is hard to tell.

His idea to rank them and take the best one is sound, and doesn't require a threshold. The issue is defining a goodness measure, because it isn't clear what makes one alternative better than another.

To do thresholding you still need a goodness measure (so it doesn't make the problem any easier), and specifying a threshold is going to cause other problems as well. How do you set the threshold? What does having a threshold gain over just taking the best from each group? What do you do when two alternatives are above/below the threshold?

Graviton v2
Mar 2, 2007

by angerbeet

Nippashish posted:

His idea to rank them and take the best one is sound, and doesn't require a threshold. The issue is defining a goodness measure, because it isn't clear what makes one alternative better than another.

To do thresholding you still need a goodness measure (so it doesn't make the problem any easier), and specifying a threshold is going to cause other problems as well. How do you set the threshold? What does having a threshold gain over just taking the best from each group? What do you do when two alternatives are above/below the threshold?
Well it depends on the requirements which are not clear (to me) at the moment. If 'Good' is required to always 100% be 'Good' then a threshold approach cant work. If however 'Good' is only needed to 90% success rate that approch will work.

Basically Carthag I think you need to give us some more info here if you can.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I know that many languages have first-class functions. What scripting languages have first-class types, in the sense that a function can return a type? So for example a function can return the type integer. (which is not nearly the same thing as returning an integer.)

Example: suppose a scripting language allows you to use decimal types to carry out calculations to arbitrary (but obviously, finite) numbers of decimal places. So you might have a function decimal() taking one argument that returns a type representing decimals accurate to the number of decimal places represented by the argument. Then if I wanted to calculate the square root of 2 correct to 50 decimal places, I might write something like

decimal(50)::sqrt(2);

in which :: is meant to be the static member operator, with sqrt() being a static method of the type returned by decimal().

Are there any scripting languages that exhibit behaviour resembling what I describe? Or am I describing something that cannot work?

(I say scripting language because I have in mind that this should be something that works through dynamic typing, which is something I perceive to be characteristic of scripting languages.)

Hammerite fucked around with this message at 11:11 on Aug 9, 2011

Carthag Tuek
Oct 15, 2005

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



Graviton v2 posted:

Well it depends on the requirements which are not clear (to me) at the moment. If 'Good' is required to always 100% be 'Good' then a threshold approach cant work. If however 'Good' is only needed to 90% success rate that approch will work.

Basically Carthag I think you need to give us some more info here if you can.

Well they're artist names; and my boss is annoyed that they aren't the same rows in the DB (which I'll agree is a legitimate concern). The data itself comes from external partners and is outside our control. So what we're doing is marking "artist A" as a duplicate of "artist B" so when someone attempts to use "artist A" in the future, they'll receive "artist B" instead.

But I don't have any better definition of "best" than "Boss will know it when he sees it." So maybe my question is more like "can you think of edge cases where using 'unicode is furthest from ascii' as the qualifier will cause problems?"

Jurgen => Jürgen
Raul => Raúl
etc are all good.

tef
May 30, 2004

-> some l-system crap ->

Hammerite posted:

I know that many languages have first-class functions. What scripting languages have first-class types, in the sense that a function can return a type?

Python

Hammerite
Mar 9, 2007

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

tef posted:

Python

OK, further question. A brief search shows that in Python, when you want to declare a function f you do so by writing

code:
def f(x):
    function body
(or something of the sort). This is similar to how in other languages one writes

code:
function f (x) {
    function body
}
This seems to betray a failure to truly treat functions as ordinary values just like any other type of values. If they were really so, you should have to write

code:
f = function (x) {
    function body
}
instead. Perhaps you can indeed do something like this in Python, I do not know. But my question is, why is the def version valid? It ought not to be.

A similar consideration applies to declaring classes. Instead of writing

code:
class c:
    class body
it ought only to be valid to write something like

code:
c = class {
    class body
}

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
MY CONSISTENCY

python eschews anonymous definitions -- ask yourself how you would do this in a language without braces.

anyway, def and class both bind to a variable in that space. it's a syntactical difference i.e def foo():pass; x=foo; x()

tef fucked around with this message at 12:47 on Aug 9, 2011

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