Difference between pages "Template:Hidelist" and "Talk:ASH Errors"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>StDoodle
(Created page with '<div class="NavFrame {{#if:{{{expand|}}}||collapsed}}" style="{{#if:{{{frame_style|}}}{{{framestyle|}}} |{{{frame_style|}}}{{{framestyle|}}} |border:none; padding:0;}}"> <div…')
 
imported>Heeheehee
m
 
Line 1: Line 1:
<div class="NavFrame {{#if:{{{expand|}}}||collapsed}}" style="{{#if:{{{frame_style|}}}{{{framestyle|}}} |{{{frame_style|}}}{{{framestyle|}}} |border:none; padding:0;}}">
+
Is this like were things like <font color="#ff7000">Script parsing error (X.ash, line Y)</font> are listed?--[[User:Icon315|Icon315]] 22:33, 14 April 2010 (UTC)
    <div class="NavHead" style="{{#if:{{{title_style|}}}{{{titlestyle|}}} |{{{title_style|}}}{{{titlestyle|}}} |background:transparent;" align="left}}"><!--
+
 
    -->{{#if:{{{title|}}} |{{{title|}}} |List}}<!--
+
:It's where they WILL be listed, once they are listed. --[[User:Bale|Bale]] 22:52, 14 April 2010 (UTC)
--></div>
+
 
    <div class="NavContent" style="{{#if:{{{list_style|}}}{{{liststyle|}}} |{{{list_style|}}}{{{liststyle|}}} |text-align:left;}}"><!--
+
What Bale said. Also, I changed that to orange; I kept trying to click on it. :( --[[User:StDoodle|StDoodle (#1059825)]] 00:35, 15 April 2010 (UTC)
    -->{{#if:{{{1|}}}  |{{{1|}}}      }}<!--
+
 
    -->{{#if:{{{2|}}}  |<br />{{{2|}}}  }}<!--
+
Also, if anyone's feeling particularly ambitious, https://kolmafia.svn.sourceforge.net/svnroot/kolmafia/src/net/sourceforge/kolmafia/textui/Parser.java should help. Just look for all the instances of parseException. (Speaking of which, would it be useful if these were presented in the order that they're checked?) --[[User:Heeheehee|Heeheehee]] 00:17, 17 April 2010 (UTC)
    -->{{#if:{{{3|}}}  |<br />{{{3|}}}  }}<!--
+
 
    -->{{#if:{{{4|}}}  |<br />{{{4|}}}  }}<!--
+
I think alphabetical order would be better: this page is going to be excellent for first-time ASH scripters to understand what's wrong with their script. --[[User:Slyz|Slyz]] 10:41, 17 April 2010 (UTC)
    -->{{#if:{{{5|}}}  |<br />{{{5|}}}  }}<!--
+
 
    -->{{#if:{{{6|}}}  |<br />{{{6|}}}  }}<!--
+
Should we add the correct examples? Or are the fixes clear enough?
    -->{{#if:{{{7|}}}  |<br />{{{7|}}}  }}<!--
+
--[[User:Slyz|Slyz]] 08:36, 18 April 2010 (UTC)
    -->{{#if:{{{8|}}}  |<br />{{{8|}}}  }}<!--
+
 
    -->{{#if:{{{9|}}}  |<br />{{{9|}}}  }}<!--
+
If anything particularly complicated shows, we can give both. But so far, if you can't follow as written, I'm not sure you ever will. (That's the hypothetical "you," not the specific "hey Slyz what's wrong with you, you"). --[[User:StDoodle|StDoodle (#1059825)]] 23:35, 19 April 2010 (UTC)
    -->{{#if:{{{10|}}} |<br />{{{10|}}} }}<!--
+
 
    -->{{#if:{{{11|}}} |<br />{{{11|}}} }}<!--
+
 
    -->{{#if:{{{12|}}} |<br />{{{12|}}} }}<!--
+
 
    -->{{#if:{{{13|}}} |<br />{{{13|}}} }}<!--
+
{{CodeSample|description=The following code results in an error.
    -->{{#if:{{{14|}}} |<br />{{{14|}}} }}<!--
+
|code=<syntaxhighlight>
    -->{{#if:{{{15|}}} |<br />{{{15|}}} }}<!--
+
void my_function( string myvar = "value" )
    -->{{#if:{{{16|}}} |<br />{{{16|}}} }}<!--
+
{
    -->{{#if:{{{17|}}} |<br />{{{17|}}} }}<!--
+
  /* Do something */
    -->{{#if:{{{18|}}} |<br />{{{18|}}} }}<!--
+
}
    -->{{#if:{{{19|}}} |<br />{{{19|}}} }}<!--
+
</syntaxhighlight>}}
    -->{{#if:{{{20|}}} |<br />{{{20|}}} }}<!--
+
Error message: <blockquote>Cannot initialize parameter myvar (filename.ash, line X)</blockquote>
    -->{{#if:{{{21|}}} |<br />{{{21|}}} }}<!--
+
I'd like to add this to the article myself, but I'm not sure how to explain its exact nature. Would this message appear only in a situation like the above code? --[[User:PhilmASTErpLus|PhilmASTErpLus]] 09:30, 28 July 2010 (UTC)
    -->{{#if:{{{22|}}} |<br />{{{22|}}} }}<!--
+
: Looks like a conflict of functionality -- the two ways to initialize a variable are '''string myvar''' and '''string myvar = "value"'''. The only proper way to define a parameter is the former. So basically you're defining a parameter, which then gets initialized with a value. This would lead to all sorts of problems, so the parser catches this exception and throws an error. I'm not really sure why anyone would want to do this, but I guess you can add it? (fun fact: the value that you set the parameter to doesn't actually have to match the datatype for this error to appear) --[[User:Heeheehee|Heeheehee]] 16:47, 28 July 2010 (UTC)
    -->{{#if:{{{23|}}} |<br />{{{23|}}} }}<!--
+
 
    -->{{#if:{{{24|}}} |<br />{{{24|}}} }}<!--
+
I'm guessing he tried it for the same reason I did; in some languages, that's how you provide a default value for a parameter. It's usually functionally equivalent to having two different versions of my_function() defined, one which accepts a single string, and one which accepts no parameters, and calls the other with the default value. Usually it isn't a big deal to do things one way or the other, but the method given above can actually be much simpler if you get into a large number of overloaded versions of a single function. --[[User:StDoodle|StDoodle (#1059825)]] 18:30, 28 July 2010 (UTC)
    -->{{#if:{{{25|}}} |<br />{{{25|}}} }}<!--
+
: In that case, would this be a reasonable low-priority feature request? --[[User:Heeheehee|Heeheehee]] 18:44, 28 July 2010 (UTC)
    -->{{#if:{{{26|}}} |<br />{{{26|}}} }}<!--
+
 
    -->{{#if:{{{27|}}} |<br />{{{27|}}} }}<!--
+
That's up to the devs, but I have a feeling it would be a non-trivial change to get a trivial benefit, and therefore ignored. Unless someone has a good argument for a situation in which it would make a huge difference. --[[User:StDoodle|StDoodle (#1059825)]] 21:08, 28 July 2010 (UTC)
    -->{{#if:{{{28|}}} |<br />{{{28|}}} }}<!--
+
 
    -->{{#if:{{{29|}}} |<br />{{{29|}}} }}<!--
+
 
    -->{{#if:{{{30|}}} |<br />{{{30|}}} }}<!--
+
{{CodeSample|description=Hardly worth suggesting. The KoLmafia method works just fine:
    -->{{#if:{{{31|}}} |<br />{{{31|}}} }}<!--
+
|code=<syntaxhighlight>
    -->{{#if:{{{32|}}} |<br />{{{32|}}} }}<!--
+
void my_function()
    -->{{#if:{{{33|}}} |<br />{{{33|}}} }}<!--
+
{
    -->{{#if:{{{34|}}} |<br />{{{34|}}} }}<!--
+
  my_function("value");
    -->{{#if:{{{35|}}} |<br />{{{35|}}} }}<!--
+
}
    -->{{#if:{{{36|}}} |<br />{{{36|}}} }}<!--
+
</syntaxhighlight>}}
    -->{{#if:{{{37|}}} |<br />{{{37|}}} }}<!--
+
--[[User:Bale|Bale]] 04:31, 29 July 2010 (UTC)
    -->{{#if:{{{38|}}} |<br />{{{38|}}} }}<!--
+
:Yeah, when I posted that code, I wasn't thinking about requesting for a default parameter feature. All I'd like to know is whether there is a general case that will trigger this particular error message; for example, I would have expected this instead of "expected ) but got =" message when I tried assignment in the conditional for the <code>if</code> and <code>while</code> statements. --[[User:PhilmASTErpLus|PhilmASTErpLus]] 13:17, 29 July 2010 (UTC)
    -->{{#if:{{{39|}}} |<br />{{{39|}}} }}<!--
+
:Bale -- I know that works nicely, but in the event that there are ten overloaded forms of one function, I might want to save a bit on typing (or copy-pasting, as the case so often happens to be). --[[User:Heeheehee|Heeheehee]] 14:45, 29 July 2010 (UTC)
    -->{{#if:{{{40|}}} |<br />{{{40|}}} }}<!--
 
    -->{{#if:{{{41|}}} |<br />{{{41|}}} }}<!--
 
    -->{{#if:{{{42|}}} |<br />{{{42|}}} }}<!--
 
    -->{{#if:{{{43|}}} |<br />{{{43|}}} }}<!--
 
    -->{{#if:{{{44|}}} |<br />{{{44|}}} }}<!--
 
    -->{{#if:{{{45|}}} |<br />{{{45|}}} }}<!--
 
    -->{{#if:{{{46|}}} |<br />{{{46|}}} }}<!--
 
    -->{{#if:{{{47|}}} |<br />{{{47|}}} }}<!--
 
    -->{{#if:{{{48|}}} |<br />{{{48|}}} }}<!--
 
    -->{{#if:{{{49|}}} |<br />{{{49|}}} }}<!--
 
    -->{{#if:{{{50|}}} |<br />{{{50|}}} }}<!--
 
--></div>
 
</div><noinclude>
 
words words words
 
</noinclude>
 

Revision as of 14:45, 29 July 2010

Is this like were things like Script parsing error (X.ash, line Y) are listed?--Icon315 22:33, 14 April 2010 (UTC)

It's where they WILL be listed, once they are listed. --Bale 22:52, 14 April 2010 (UTC)

What Bale said. Also, I changed that to orange; I kept trying to click on it. :( --StDoodle (#1059825) 00:35, 15 April 2010 (UTC)

Also, if anyone's feeling particularly ambitious, https://kolmafia.svn.sourceforge.net/svnroot/kolmafia/src/net/sourceforge/kolmafia/textui/Parser.java should help. Just look for all the instances of parseException. (Speaking of which, would it be useful if these were presented in the order that they're checked?) --Heeheehee 00:17, 17 April 2010 (UTC)

I think alphabetical order would be better: this page is going to be excellent for first-time ASH scripters to understand what's wrong with their script. --Slyz 10:41, 17 April 2010 (UTC)

Should we add the correct examples? Or are the fixes clear enough? --Slyz 08:36, 18 April 2010 (UTC)

If anything particularly complicated shows, we can give both. But so far, if you can't follow as written, I'm not sure you ever will. (That's the hypothetical "you," not the specific "hey Slyz what's wrong with you, you"). --StDoodle (#1059825) 23:35, 19 April 2010 (UTC)


The following code results in an error.

void my_function( string myvar = "value" )
{
   /* Do something */
}

Error message:

Cannot initialize parameter myvar (filename.ash, line X)

I'd like to add this to the article myself, but I'm not sure how to explain its exact nature. Would this message appear only in a situation like the above code? --PhilmASTErpLus 09:30, 28 July 2010 (UTC)

Looks like a conflict of functionality -- the two ways to initialize a variable are string myvar and string myvar = "value". The only proper way to define a parameter is the former. So basically you're defining a parameter, which then gets initialized with a value. This would lead to all sorts of problems, so the parser catches this exception and throws an error. I'm not really sure why anyone would want to do this, but I guess you can add it? (fun fact: the value that you set the parameter to doesn't actually have to match the datatype for this error to appear) --Heeheehee 16:47, 28 July 2010 (UTC)

I'm guessing he tried it for the same reason I did; in some languages, that's how you provide a default value for a parameter. It's usually functionally equivalent to having two different versions of my_function() defined, one which accepts a single string, and one which accepts no parameters, and calls the other with the default value. Usually it isn't a big deal to do things one way or the other, but the method given above can actually be much simpler if you get into a large number of overloaded versions of a single function. --StDoodle (#1059825) 18:30, 28 July 2010 (UTC)

In that case, would this be a reasonable low-priority feature request? --Heeheehee 18:44, 28 July 2010 (UTC)

That's up to the devs, but I have a feeling it would be a non-trivial change to get a trivial benefit, and therefore ignored. Unless someone has a good argument for a situation in which it would make a huge difference. --StDoodle (#1059825) 21:08, 28 July 2010 (UTC)


Hardly worth suggesting. The KoLmafia method works just fine:

void my_function()
{
   my_function("value");
}

--Bale 04:31, 29 July 2010 (UTC)

Yeah, when I posted that code, I wasn't thinking about requesting for a default parameter feature. All I'd like to know is whether there is a general case that will trigger this particular error message; for example, I would have expected this instead of "expected ) but got =" message when I tried assignment in the conditional for the if and while statements. --PhilmASTErpLus 13:17, 29 July 2010 (UTC)
Bale -- I know that works nicely, but in the event that there are ten overloaded forms of one function, I might want to save a bit on typing (or copy-pasting, as the case so often happens to be). --Heeheehee 14:45, 29 July 2010 (UTC)