Lambda expressions and compiler extensions

Hi guys,
I'm working on a project that is designed to play nicely with closures (anonymous functions) and it would be really nice if lambda expressions were supported due to the abbreviated syntax.
I posted a question on these forums last year and the reply mentions a "custom asc extension". Is the compiler (even if it's just 4.0) extensable in a way that support for lambda expressions could be added? If it's not *that* extensible, how much effort would be involved?
If it's simply not possible, can I make a language request for the next release?
Cheers,
Richard
PS. FYI, here are the requirements for a lambda expressions as they would work in the AVM:
"x:int => x + 1" is equivalent to "function (x:int) : int { return x+1; }"
"(x:int) => methodThatReturnsVoid(x)" is equivalent to "function (x:int) : void { methodThatReturnsVoid(x); }"
"() => 5" is equivalent to "function () : int { return 5; }"
"_ => 5" is equivalent to "function (_ : Object) : int { return thereIsAnArgumentButIWontUseIt(); }"
"() =>
    bracesMeansICanUseMultipleStatements();
    return butIHaveToUseReturn();
is equivalent to
"function():void
    bracesMeansICanUseMultipleStatements();
    return butIHaveToUseReturn();
... etc

I think you misunderstood my post. I was asking for a pointer in the right direction to implement the support myself, and how the extension would integrate into an existing sdk installation.
I realise that AS3 is not intended to match C# feature-for-feature, but I've been working on a port of Rx and lambda-syntax for anonymous functions would be much more pleasing on the eye.
Besides, if I were set on requesting a feature, it'd be proper generics support!

Similar Messages

  • C# compiling error: 'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)

    Hello experts,
    I'm totally new to C#. I'm trying to modify existing code to automatically rename a file if exists. I found a solution online as follows:
    string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
            string tempFileName = fileName;
            int count = 1;
            while (allFiles.Contains(tempFileName ))
                tempFileName = String.Format("{0} ({1})", fileName, count++); 
            output = Path.Combine(folderPath, tempFileName );
            string fullPath=output + ".xml";
    However, it gives the following compilation errors
    for the Select and Contain methods respectively.:
    'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found
    (are you missing a using directive or an assembly reference?)
    'System.Array' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'System.Array' could be
    found (are you missing a using directive or an assembly reference?)
    I googled on these errors, and people suggested to add using System.Linq;
    I did, but the errors persist. 
    Any help and information is greatly appreciated.
    P. S. Here are the using clauses I have:
    using System;
    using System.Data;
    using System.Windows.Forms;
    using System.IO;
    using System.Collections.Generic;
    using System.Text;
    using System.Linq;

    Besides your issue with System.Core, you also have a problem with the logic of our code, particularly your variables. It is confusing what your variables represent. You have an infinite loop, so the last section of code is never reached. Take a look 
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    namespace consAppFileManipulation
    class Program
    static void Main(string[] args)
    string fullPath = @"c:\temp\trace.log";
    string folderPath = @"c:\temp\";
    string fileName = "trace.log";
    string output = "";
    string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath);
    string extension = Path.GetExtension(fullPath);
    string path = Path.GetDirectoryName(fullPath);
    string newFullPath = fullPath;
    string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
    string tempFileName = fileName;
    int count = 1;
    //THIS IS AN INFINITE LOOP
    while (allFiles.Contains(fileNameOnly))
    tempFileName = String.Format("{0} ({1})", fileName, count++);
    //THIS CODE IS NEVER REACHED
    output = Path.Combine(folderPath, tempFileName);
    fullPath = output + ".xml";
    //string fullPath = output + ".xml";
    UML, then code

  • Qualifying Expression and WHERE CLAUSE Extension

    I would like to know the exact difference between 'Qualifying Expression and WHERE CLAUSE Extension'. Since both are meant to contain some CONDITION that would facilitate the Edit Check's success, So I am sometimes a bit confused with these too as to when to use what.
    Can someone help Please??

    As you can tell from my previous posts (requests!) - I'm a newbie to OC.
    From the documentation - it appears that both Qualifying expression and Where Clause work the same way but the way they execute is different.
    Qualifying expression is applied after the fetch (key fields and question response data from DCM cursor i.e., after the cursor fetches the data) and Where clause filters before QG fetch.
    HTH

  • IEnumerable T Property as parameter in Lambda Expression

    Hi,
    I have following construction which returns selected items from the list:
    public IEnumerable<Country> SelectedProducts
    get
    return this.Countries.Where(c => c.ContinentName.Equals("Product Catalog") && c.IsSelected);
    }The following construction foreach (Country c in SelectedProducts)
    MessageBox.Show(c.ProductName.ToString());
    returns product names for selected products in list. How can I use SelectedProducts and pass the same into lambda expression to retrieve data from database. Since it contains multiple values it should be used something like with IN expression in T-SQL
    or not. Please help in order to get this working.
    Thanks in advance.
    Almir

    Hello Barry,
    I converted Selectedproducts
     public
    IEnumerable<Country>
    SelectedProducts
                get
    return this.Countries.Where(c
    => c.ContinentName.Equals("Product
    Catalog") && c.IsSelected); 
    to string[] array using construct SelectedProductsToString and then pass it to where clause as it is shown in ShowSelected() method.
    private string[] SelectedProductsToString
    get
    return SelectedProducts.Select(c => c.ProductName.ToString()).ToArray();
    public void ShowSelected()
    var result = Fact.Where(c=> SelectedProductsToString.Contains(c.ProductName));
    Do you think it's ok from your point of view or should consider something else.
    Thanks for your opinion.
    Regards.
    Almir

  • How do I install a new airport express and link a second airport express to extend the network of the first airport express?

    I currently have a linksys wireless router attached to the Internet.  I have an A1264 Airport Express connected by Ethernet to the linksys router.  I have two network names, one for each wireless network.
    I purchased a new A1392 Airport Express to replace the linksys router and join to the A1264 Airport Express, and I want to have one network name as a result.
    How do I do this?  I realize that I have to reconfigure the A1264 device so that it is an extension of the A1392 device.

    You have a fairly complicated set up, so I suggest that it would make sense to tackle things in stages, testing each stage as  you go, before proceding to the next stage.
    Stage 1 would be setting up the A1392 first to the cable modem, and then making sure that everything is working correctly on the A1392 Express
    Stage 2 would be adding the Netgear switch and testing each port with a laptop connected via Ethernet to make sure that everything is operational on the switch
    Stage 3 would be connecting the A1264 Express and testing to make sure that it is extending the network correctly
    Stage 4 would be adding other Ethernet devices to the Netgear switch and testing each one at a time before adding the next device. There is some question about whether an iOS device can print to an Ethernet connected printer....even if the printer is AirPrint compatible. You may need to connect the HP using wireless...not Ethernet....to gain full AirPrint functionality, or use another application that will allow printing like Printopia or Print Central using the Ethernet connection on the HP.
    Stage 5 would be adding the printer to the A1264 AirPort Express.
    You do not mention how the printer will connect to the A1264 Express, but I assume that it will be USB from your description.  Most printers will work, but you really will not know if your printer will work until you try.
    Remember that only printing will be supported at the USB port of the Express. If you have an all-in-one type device, scan, maintenance, and other advanced features will not be operational whent the device is connected to the AirPort Express.
    If you want to print from an iOS device like an iPad or iPhone, plan to add additonal software like Printopia or Print Central to possibly allow this function. There are no guarantees here as far as the iOS devices.

  • Php with mysqli, mbstring and xsl extensions

    I don't understand why php isn't build with mysqli and mbstring extensions since mysql4 is installed and there are a lot of languages that need multibytes strings. Here is a PKGBUILD that enable them. I also added xsl extension to use xsl files with php.
    # $Id: PKGBUILD,v 1.51 2004/12/16 22:03:19 judd Exp $
    # Maintainer: dorphell <[email protected]>
    # Contributor: Benoit Chesneau <[email protected]>
    pkgname=php
    pkgver=5.0.3
    pkgrel=2
    pkgdesc="A high-level scripting language"
    url="http://www.php.net"
    backup=(etc/php.ini)
    depends=('openssl' 'libjpeg' 'freetype2' 'libpng' 'pam'
    'gdbm' 'libxml2' 'openldap' 'ncurses' 'curl' 'libxslt')
    makedepends=('apache' 'mysql' 'imap' 'postgresql' 'bzip2' 'smtp-server'
    'gd' 'fam' 'sqlite3' 'unixodbc')
    source=(http://www.php.net/distributions/$pkgname-$pkgver.tar.gz php.ini)
    md5sums=('bf89557056ce34d502e20e24071616c7' 'd5b9b37fbb746f0967d795763106735a')
    build() {
    cd $startdir/src/$pkgname-$pkgver
    ./configure --with-apxs2 --prefix=/usr --sysconfdir=/etc
    --with-layout=PHP
    --with-ttf --enable-mailparse --with-config-file-scan-dir=/etc
    --enable-bcmath=shared --enable-calendar=shared --enable-ftp=shared
    --enable-gd-native-ttf --enable-magic-quotes --enable-posix=shared
    --enable-session --enable-shared --enable-shmop=shared --with-imap
    --with-imap-ssl --with-ncurses --with-readline --with-sqlite=shared
    --enable-sysvsem=shared --enable-sysvshm=shared --enable-track-vars
    --enable-trans-sid --enable-safe-mode --enable-sockets=shared
    --enable-xml --with-bz2=shared --with-curl --with-mime-magic
    --with-unixODBC=shared
    --enable-dba --without-db2 --without-db3 --with-inifile --with-flatfile
    --with-gdbm --with-freetype-dir=/usr --with-gd=shared --enable-exif
    --with-jpeg-dir=/usr --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config
    --with-ldap=shared
    --with-mysql-sock=/tmp/mysql.sock --with-openssl --with-gettext
    --with-pear=/usr/share/pear --with-dom --with-dom-xslt
    --with-pgsql=shared --with-pgsql-sock=/tmp/pgsql.sock
    --with-png-dir=/usr --with-regex=php --with-zlib --with-fam=shared
    --with-xsl
    --enable-mbstring=all --enable-mbregex
    # fixes a build error in sqlite support
    ln -s main/php_config.h ./config.h
    make || return 1
    mkdir -p $startdir/pkg/usr/lib/apache
    # cp config_vars.mk config_vars.old
    # sed "s|^INSTALL_IT.*$|INSTALL_IT = apxs -i -a -S LIBEXECDIR=$startdir/pkg/usr/lib/apache -n php4 libs/libphp4.so|" config_vars.old >config_vars.mk
    sed -i "s|-i -a -n php5|-i -n php5|g" Makefile
    make INSTALL_ROOT=$startdir/pkg EXTENSION_DIR=/usr/lib/php install
    cp ../php.ini $startdir/pkg/etc

    i suggest filing a feature request through the bug tracker.
    As for why such features may not be compiled in is that whoever maintains the package may have never had the need to have such features in php or experienced any issue because of it. You will experience this with many distros so I suggest not getting accusatory and simply request the feature through the proper channels.
    Each persons needs and experience are different and that is why developers write their code to encompass as many features as their users request.  How robust a package needs to be in arch is up to people like you giving the crucial feedback.
    (btw i don't see why your request would not be granted. I suggest the feature request though because i know the maintainer of the PHP package is not a frequent visitor to this forum but he will get your request if you make to the bug tracker)

  • What are shortest file names for outlook express and PSE11 to import photos pls

    what are shortest file names for outlook express and PSE11 to import photos pls

    Hi, Troubled. The size of the file name is pretty much irrelevant here to PSE, but to answer your question directly, you will be able to import a file that has only a single character as its file name (plus the file name needs to have the required extension, such as .jpg)

  • Solved: AirPort Express and AirTunes Audio Distortion Connected to a Stereo

    *The problem*: Terrible sound distortion while using AirPort Express AirTunes features. Even when nothing was plugged in, there would be a buzzing noise.
    *The setup*: AirPort Express connected via 3.5mm stereo jack to a pair of computer stereo speakers. Note: This post does not apply to you if you are using an optical Toslink between the AirPort Express and your speakers. iTunes installed on a Mac. AirTunes setup to allow music to stream wirelessly to AirPort Express and speakers.
    *The solution*: The AirPort Express needs to be grounded. The included AC tip is only two prong. In the US, the third prong (round) is used for grounding.
    Therefore you just need to attach the three prong AC tip. This is not included with the AirPort Express. What you need is the Apple Power Extension Cord which has a 3 prong tip.
    Example:
    http://www.amazon.com/Adapter-Extension-Apple-PowerBook-Notebook/dp/B002V4XKRS
    This is the same extension cord that comes with most Apple notebooks.
    Hope this helps!

    Bob,
    This is really simple so no instructions are necessary.
    Plug in the new Express when you get it and have it "Join the existing network"...
    Give the iTunes Music section a name like "Front Room Stereo" and that's it...
    Plug the stereo into the Express and select it in iTunes for playing music.
       Joseph Kriz
           <img src="http://images.apple.com/search/images/waitanimation.gif" alt="wheel"

  • BPEL and BPEL extensionS

    I went through BPEL specification in which BPEL extensions for executables and business protocols are also described.
    Can anybody tell me how BPEL extension are different from BPEL. I am getting preliminary expression that BPEL extensions lack something what BPEL has.
    Kimdly clarify these two.
    THAT WOULD BE OF GREAT HELP FOR ME

    This functionlaity is part of the stadard, in other words - you can wrtie your own extensions through this feature, and allowed to do so .. BUT it is not a must to support these (hand implemented) functions from a vendor perspective - the extension feature has to be supported ..
    Other things such as wsdl use this too (e.g. a partnerlink is based on wsdl extension)

  • Question about SunStudio v12.3 and compiling on multicore multithreaded T5240

    Hi,
    I purchased the first multicore/multithreaded server for our company to replace SunFire V240 and v445.  The server I got is T5240 with 2x4 core 1.2GHz CPUS.
    I am running Sparc Solaris 10u11 on this server
    I installed SunStudio v12.3 and compiled mysql v5.5.19, which took an hour.  When I compiled on a SunFire v240 with 2 1.5G CPUs, the the compile took 1/2hour.  Now I know the single CPU on the 5240 is smaller than the v240 but I thought it would be faster on the 5240. I used the same compile script (see below).
    Is compiling a program just use a single CPU no matter what the capabilities?  Is there an option I can pass to have it use all the server resources so it can compile faster?   This is a web server and I want to make sure all the programs I compile can utilize all the capabilities of the cores and threads.
    If this is not the forum for this, any suggestions on where I can get help with this would be appreciated.
    Thank you.
    -----------------------------------  mysql compile script -------------------------------
    #!/bin/sh
    PATH=/opt/SUNWspro/bin:/usr/ccs/bin:/usr/sfw/bin:/usr/local/bin:.:/usr/bin:/usr/sbin:/usr/ucb:/etc:/usr/local/cmake/bin; export PATH
    CC=cc; export CC
    CXX=CC; export CXX
    /usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home1/mysql_data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1

    Each compilation is single-threaded. When you run a serial make, you get one compilation at a time.
    The way to improve throughput is to use a parallel make that can run more than one task simultaneously. I am not familiar with cmake. I took a quick look at the documentation at cmake.org, but could not tell whether cmake offers a parallel make option. Both GNU gmake and the dmake that comes with Studio do. (Studio dmake is the same as Solaris make, with extensions for parallel and distributed job management.) Assuming  there is enough memory, I use a rule of thumb of setting the max parallel jobs at 1 per core. You can find out the number of cores on Solaris this way:
         /usr/sbin/psrinfo | grep -c on-line
    Setting up the makefile for parallel make requires some attention to be sure you don't try to build parts out of sequence. Either all dependencies must be made explicit, or you need a way to say "wait for A to be done before starting B". (Both gmake and dmake have this feature.)  I don't know whether mysql makefiles are ready for parallel make, but you can probably find out at mysql.org, along with whether it works with dmake or gmake. (Each make variation has some usually minor incompatibilities with the others.)
    Message was edited by: Steve_Clamage

  • Installing and Compiling COBOL on Windows

    Hi, I am at Installing and Compiling COBOL on Windows of PeopleTools_8.52_Installation_Oracle.pdf. After I typed in (basic syntax from pdf):
    CBLMAKE.BAT [] [ALL] [wildcard filename[ALL]] [wildcard filename | wildcard filename without extension[INT | GNT | EXE]] [EBCDIC] [LIST]
    This error appears:
    'wildcard' is not recognized as an internal or external command,
    operable program or batch file.
    Any advise? Thanks

    but now my step is after this already---> cblsrc PS_HOME C:\temp\compile
    After this step, it asks me to change directories to the compile directory which i think is (cd C:\temp\compile), and run CBLMAKE.BAT, using the basic syntax..... and I got that error... How can I do about it?

  • Regular expression and XML

    Hello,
    I have an XML file containing regular expressions and i parse the file, extract the pattern from it and search for it using java regex package. The problem is it works fine when patterns are words but when the pattern is something like
    write \\d+ (write followed by a space followed by one or mre digits) it doesn't work.
    I wrote the same code but with the pattern embedded in it,ie. without using XML and it worked. But when extracting with XML it fails.
    Also if the pattern is write[0-9] it only extracts write[0-9 and gives an error of no closing bracket.
    Could anyone please tell me what i am missing out
    Thank you

    thank you for your replies. Well i have still no got over the problem so i am posting my code here and hoping it can get solved
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.io.*;
    import java.util.regex.*;
    class textextractor extends DefaultHandler{
         boolean regex=false;
    public void startElement(String namespaceURI,String localName,String qn,Attributes attr)
              if(localName.equals("REGEX"))
               regex=true;
    public void characters(char [] text,int start,int length)throws SAXException {
              String t=new String(text,start,length);
              boolean flag=false;
              if(regex==true)
                Pattern pattern;
                  String w=new String(t);
              pattern = Pattern.compile(w);
              Matcher matcher;
              matcher=pattern.matcher("there is a bat   read  write 13    error at line ");
              while(matcher.find())
               flag=true;
               System.out.println("I found the text \"" + matcher.group() +"\" starting at index "
               + matcher.start() +"and ending at index " + matcher.end() + ".");
             if(!flag)
               System.out.println("not found");
             regex=false;
    public class saxt2 {
         public static void main(String args[]) {
              try {
                    XMLReader parser= XMLReaderFactory.createXMLReader();
                    ContentHandler handler=new textextractor();
                    parser.setContentHandler(handler);
                                    parser.parse("d:\\regex.xml");
                  }catch (Exception e) {
                   System.err.println(e);
    }The xml file is
                      <RegularExpression>
                      <REGEX>write</REGEX>
                      <REGEX>write \\d+</REGEX>
                      <REGEX>read[0-9]</REGEX>
                      </RegularExpression>by running the code you can see that write is found,write \\d+ doesn't match write 13 in the string and read[0-9] gives and error.
    Any help will be greatly appreciated

  • Airport Express and HP F4180 All in One Printer

    Hi 
    I just bought an Apple Airport Express to connect my F4180 to my wireless home network. This F4180 used to be connected directly via USB to my Vista PC and was available to the other laptops by sharing the printer. This worked ok, but I always had to start this specific computer to make the F4180 available for the other laptops.
    After installing the Airport Express and Bonjour everything seemed perfect, but after the first print I noticed that only 60% of the page was printed and an error occured. I tried everything, installing, reinstalling, deleting, reading forums, helpdesks, etc, etc, but did not find an answer.
    Does anyone have a clue?
    Thanx in advance
    Henri
    Vista,
    HP F4180 All in One printer,
    Apple Airport Express (latest version),
    Apple Bonjour (latest version),
    Linksys E200 wireless
    Apple Airport Express installed as extension of existing network

    This combination SHOULD work but it often does not.  I have replaced several base routers from non-Airport to Airport and resolved issues like this - USB printers, AirPlay issues, etc.  Its the only way I know how to make it work, sorry.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Airport Express and piano

    I am currently using my MAC to send midi files through a Yamaha UX16 to my player piano to have it play the files. It uses "port 1", the USB out of the MAC.
    Will the USB of the Airport Express act just like the USB "out" of the MAC (as if it was plugged in directly)?
    In other words, can I send the midi file to the Airport Express and let it be called a port?

    No, the USB port on an AirPort Extreme does not work like that. It cannot be used as an extension of the USB port on a computer. It can only be used for sharing a USB printer.

  • VoiceView Express and Messages Button

    Hi,
    I have Unity Express 8.0.5 integrated with CUCM 8.0.
    Users have 7945 and 7965 IP phones and use Extension Mobility.
    I have configured VoiceView Express and it is working ok but users find that having to press the Services button and then scroll to the service is a chore. Unfortunately I cannot assign the service URL to a button as the 7945 phones use button 1 for a line and button 2 for HLog.
    I would like to know if there is any way of programming the Messages button on the phones so that VoiceView Express runs when it is pressed.
    Thanks!

    Hi Steven,
    Thanks for the response. I have managed to get it working by following pretty much what you said.
    I defined a new IP phone service with type Messages and subscribed my phone to it and when I press the Messages button I get two options on the screen - "Voicemail" which when selected launches the CUC TUI and VoiceView Express.
    I did not have to modify the Messages URL on the phone to get this working.
    My problems are now how to remove the Voicemail option - it is an Enterprise subscription and then how to subscribe the Extension Mobility User Device Profiles to the new VoiceView Express service as BAT does not support doing this
    I guess I should have done a bit more testing before configuring all the users.
    I do think that Cisco maybe need to review which IP phone services need to be Enterprise Subscriptions by default. I would like to see Voicemail and Personal Directory modified so they are not Enterprise subscriptions out of the box.
    Thanks again

Maybe you are looking for

  • Sun One (Netscape) Plugin: Losing HTTP Session Problem

    Hi All, We are having some trouble with HTTP sessions. Sometimes our browser will have a session cookie set but will be issued a new session cookie anyways. This seems to occur only one in every 10 attempts, and seems to occur more frequently on cert

  • How to use multiple datasource in spring and hibernate

    HI all, I want to use multiple data source for my web application.Please suggest me the mapping of xml files viz. applicationContext-resource.xml,applicationContext-hibernate.xml and applicationContext-service.xml SHoud i create separate session fact

  • Photo Booth is "Deleted"

    Hi, my photobooth is deleted, it just vanished. It's not in my spotlight, and not in my applications folder. What happened, and what do I do?

  • BIG DUPLICATE PROBLEM

    So my computer recently got a new hard drive and when I re-installed iTunes, it just dumped all my music back into the iTunes library. The thing is, I have thousands of duplicates now, and I don't know how to get rid of them. Is there a way to do it

  • Flash for Web Banners

    I am a newbie to Flash. I recently completed a video course (well 80% of it). However, I realize that I have to actually start on a project to really apply what I have learned (in other words that's where the learning really starts through applicatio