[Swift-user] Variable Declaration
Ketan Maheshwari
ketancmaheshwari at gmail.com
Sat Mar 9 18:50:42 CST 2013
Jay,
In addition to what Mike said, please note that string is available as
built-in type with Swift. So, "type string" statement is not required.
On Sat, Mar 9, 2013 at 5:55 PM, Michael Wilde <wilde at mcs.anl.gov> wrote:
> Jay,
>
> An app() function's body is restricted to contain a single command line
> template and nothing else. So instead of:
>
> app (messagefile t) parse(messagefile n) {
> string v = @regexp("abcdefghi", "c(def)g","monkey");
> echo @extractint(n) stdout=@filename(t);
> }
>
> ...you need create a separate ("compound") function to do things like
> string v=(). You can embed arbitrary expressions in the app() body, but it
> can only have one semicolon-terminated command. Thats the likely cause of
> the syntax error.
>
> Also note that your statement "string v = ..." is creating a value that as
> far as I can see is not used anywhere, so you may want to re-examine that
> logic.
>
> - Mike
>
> ----- Original Message -----
> > From: "Jay Lee" <jlee734 at gmail.com>
> > To: swift-user at ci.uchicago.edu
> > Sent: Saturday, March 9, 2013 5:48:17 PM
> > Subject: [Swift-user] Variable Declaration
> >
> >
> > Hello,
> >
> > I just started with swift today, so excuse my lack of knowledge. I
> > have the following code:
> >
> > type messagefile;
> > type string;
> >
> > app (messagefile t) parse(messagefile n) {
> > string v = @regexp("abcdefghi", "c(def)g","monkey");
> > echo @extractint(n) stdout=@filename(t);
> > }
> >
> > app (messagefile t) greeting() {
> > echo "Hello, world!" stdout=@filename(t);
> > }
> >
> > messagefile outfile <"hello.txt">;
> > messagefile input <"compile.txt">;
> >
> > outfile = parse(input);
> >
> >
> >
> > I get an error: Could not compile SwiftScript source: line 6:10:
> > expecting a semicolon, found '='
> >
> > I found that there are mappers that can be used to declare variables
> > (namely files), but are these required?
> >
> >
> >
> > _______________________________________________
> > Swift-user mailing list
> > Swift-user at ci.uchicago.edu
> > https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> https://lists.ci.uchicago.edu/cgi-bin/mailman/listinfo/swift-user
>
--
Ketan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20130309/d3a2780d/attachment.html>
More information about the Swift-user
mailing list